Last Updated on April 4, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
How do you send email notifications for the draft emails in the case feed?Â
Draft emails allow support agents who use Case Feed to write and save messages without having to send them immediately. It also allows us to implement approval processes so that messages can be reviewed by supervisors or senior agents before they’re sent to customers. Drafts are only supported if your administrator has enabled them, but there is no such option to send reminder notifications for Draft emails.Â
Objectives:
After reading this blog post, the reader will be able to:
- Understanding Draft emails features for case
- Create an email template in Flow
- Use Flow to send a custom email alert
- and much more
Business Use case
Warren Mason is working as a System Administrator at Gurukul on Cloud (GoC). Support agents from his organization are using the email draft feature and want some enhancements. Many times they compose a new email on Case Feed and save it as a Draft. Later on, they forget to send it, so they want a reminder notification (email) for Draft emails after 2hrs of its creation.
Automation Champion Approach (I-do):
There are a few possible solutions for the above business scenario, but let’s use the After-Save Record-Triggered Flow to solve the above business requirement. Apex Triggers can also be used to solve the above business use case. Check out this article to understand why we are using after-save record-triggered flow for this scenario.Â
We are using Salesforce Flow because (as of the Spring’22Â release) Salesforce doesn’t allow us to create an email alert on the Email Message object. Hence we will use a Flow text template to construct the email and send it to the recipient.
Let’s take a pause here and review EmailMessage objects in Salesforce. Make sure to enable Email Drafts features by navigating Support Settings.
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 4 steps to solve Warren’s business requirement using Record-Triggered Flow. We must:
- Define flow properties for record-triggered flow
- Add a Text Template to construct the email body
- Add a scheduled path
- Add send email action  – to notify the email draft ownerÂ
Step 1: Define Flow PropertiesÂ
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
- Object: EmailMessage
- Trigger the Flow When: A record is created or updated
- Set Entry Criteria
- Condition Requirements: All Conditions Are Met (AND)
- Row 1:
- Field: Status
- Operator: Equals
- Value: 5
- Click Add Condition
- Row 2:
- Field: ParentId
- Operator: Is Null
- Value: {!$GlobalConstant.False}
- Row 1:
- Condition Requirements: All Conditions Are Met (AND)
- When to Run the Flow for Updated Records:Â Every time a record is updated and meets the condition requirements Â
- Optimize the Flow For Action and Related Records
- Click Done.
Step 2:Â Add a Text Template to Construct Email BodyÂ
 Now we’ll create an email template using the Text Template. The text template allowed you to specify the multi-line messages. It also allows you to use HTML code.
- Under Toolbox, select Manager, then click New Resource to create a text template.Â
- Input the following information:Â
- Resource Type: Text Template
- API Name: textT_EmailBody
- Select View as Rich Text
- BodyÂ
- Hi {!$Record.CreatedBy.FirstName},
- This is just a reminder email to notify you that, you have composed an email with Draft status on Case:- {!$Record.ParentId}
- Regards,
- Automation Champion
- Click Done.
Step 3: Salesforce Flow – Add Scheduled Paths
The purpose of using a scheduled path is to send an email notification to the case draft email owner after 2 hours.Â
- Under Start, select Add Scheduled Paths (Optional).
- Under SCHEDULED PATHS, click on the  New Scheduled Path.
- Under Scheduled Path Details, enter the Label the API Name will auto-populate.
- Time Source: EmailMessage: Last Modified Date
- Offset Number:Â 2
- Offset Options: Hours After
- Advanced Options
- Batch Size: 200
- Click Done.
Step 4: Add Send Email Action to Notify Email Message Owner
Now we will use the Send Email static action to send out an e-mail to the email message owner.Â
- On Flow Designer, below the 2 hours node, click on the +icon and select the Action element.
- Search and select the Send Email from the dropdown menu
- Enter a name in the Label field; the API Name will auto-populate.
- Set Input Values
- Body: {!textT_EmailBody}
- Subject: Email Draft Notification For Case – {!$Record.ParentId}
- Email Addresses (comma-separated): {!$Record.CreatedBy.Email}
- Rich-Text-Formatted Body: {!$GlobalConstant.True}
- Click Done.
In the end, Warren’s Flow will look like the following screenshot:
Once everything looks good, perform the steps below:Â
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- API Version for Running the Flow: 54
- Interview Label: Email notification for Draft emails {!$Flow.CurrentDateTime}
- Click Save.Â
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Now onwards if a user leaves the email (which he compose through Case Feed) in Draft status, the record-triggered flow will notify him after 2 hours.
- Now compose an email (By navigating the case detail page) and save it as a draft as shown in the following screenshot:
- You will get an email from Salesforce after 2 hours if the email is still in Draft status.
Monitor Your Schedule Flow
To monitor Flows that are scheduled, navigate to the following path:Â
- Navigate to Setup (Gear Icon) | Environments | Monitoring | Time-Based Workflow.
- Click Search.
- Now look for your Scheduled Flow job displaying information as shown in the following screenshot:
- Use the Delete button to delete the time-based Flow job from the queue.
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.
Hi, this very detailed step-by-step post on how to create a flow to notify on a draft email was so so helpful! Thank you heaps for posting this as I am still getting the hang of how to use flow.
You’re welcome!