Our customer service agents are sending emails to customers from cases through the standard "Send an Email" page where they select a template. Often they edit the text before sending.
We'd like to track which email templates are used in which cases. (Background: This is a preparation for automating parts of this. The idea is to train an AI to propose and eventually send the correct template for new cases based on the customer's message and some metadata. To create training data for the AI, we need to track which email templates are used in each case.)
My first idea:
Add new text fields on Email Message
that hold the Email Template
's id and the unique name (Salesforce does not allow lookups to Email Templates
). Then I re-build the "Send an Email" page as a Visualforce page and store the template id and unique name on the new Email Message
every time one is sent. I could then use a "cases with emails" report to get the data. Optionally store whether the email text was edited before sending.
- Pro: Only adds custom fields on
Email Message
, so storage usage is not a problem. - Cons: Have to re-build a standard page that is used with high frequency.
I'd appreciate all comments. How would you go about tracking email template usage?
<div id="templateid">00Y74000000NsvC</div>
. Then add a trigger on before/after insert on EmailMessage where you parse the body looking for that templateid value then save it in some custom object.