Email Notification for Draft Emails in Case Feed

Email Notification for Draft Emails in Case Feed

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:

  1. Define flow properties for record-triggered flow
  2. Add a Text Template to construct the email body
  3. Add a scheduled path
  4. Add send email action  – to notify the email draft owner 

Step 1: Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: EmailMessage
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: All Conditions Are Met (AND)
        1. Row 1:
          1. Field: Status
          2. Operator: Equals
          3. Value: 5
        2. Click Add Condition
        3. Row 2:
          1. Field: ParentId
          2. Operator: Is Null
          3. Value: {!$GlobalConstant.False}
    4. When to Run the Flow for Updated Records: Every time a record is updated and meets the condition requirements  
    5. Optimize the Flow For Action and Related Records
  5. 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.

  1. Under Toolbox, select Manager, then click New Resource to create a text template. 
  2. Input the following information: 
    1. Resource Type: Text Template
    2. API Name: textT_EmailBody
    3. Select View as Rich Text
    4. Body 
      1. Hi {!$Record.CreatedBy.FirstName},
      2. This is just a reminder email to notify you that, you have composed an email with Draft status on Case:- {!$Record.ParentId}
      3. Regards,
      4. Automation Champion
  3. 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. 

  1. Under Start, select Add Scheduled Paths (Optional).
  2. Under SCHEDULED PATHS, click on the  New Scheduled Path.
  3. Under Scheduled Path Details, enter the Label the API Name will auto-populate.
  4. Time Source: EmailMessage: Last Modified Date
  5. Offset Number: 2
  6. Offset Options: Hours After
  7. Advanced Options
    1. Batch Size: 200
  8. 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. 

  1. On Flow Designer, below the 2 hours node, click on the +icon and select the Action element.
  2. Search and select the Send Email from the dropdown menu
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Input Values
    1. Body: {!textT_EmailBody}
    2. Subject: Email Draft Notification For Case – {!$Record.ParentId}
    3. Email Addresses (comma-separated): {!$Record.CreatedBy.Email}
    4. Rich-Text-Formatted Body: {!$GlobalConstant.True}
  5. Click Done.

In the end, Warren’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 54
  5. Interview Label: Email notification for Draft emails {!$Flow.CurrentDateTime}
  6. 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.

  1. Now compose an email (By navigating the case detail page) and save it as a draft as shown in the following screenshot:
  2. 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: 

  1. Navigate to Setup (Gear Icon) | Environments | Monitoring | Time-Based Workflow.
  2. Click Search.
  3. Now look for your Scheduled Flow job displaying information as shown in the following screenshot:
  4. 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.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.