Admins / Developers

How to Set up Einstein Next Best Action for Emotion Analysis

By Shruti Sridharan

According to Wikipedia, emotion recognition is the process of identifying human emotion, most typically from facial expressions as well as from verbal expressions. Automatic analysis of emotions from verbal expressions uses techniques from Machine Learning (a subset of Artificial Intelligence).

In my previous post, I showed you how to successfully implement the Emotion Analysis without writing a single line of Apex. There are options for integrating Emotion Analysis with your Salesforce instance that we explored so that you can perform an analysis of emotions based on the verbal expressions that customers make every day with your organisation.

Let’s revisit the Use Case once more.

As a Support Representative, I need to analyze the emotion of the text in the Description field of a Case record created via Email to Case or Web to Case. Depending on the emotion, I want to automatically present to the Support Rep., Recommendations or the Next Best Actions that need to be executed.

In order to “show Recommendations or the Next Best Action” that the Support Representative can perform based on the analyzed emotion, we will use Einstein Next Best Action (aka NBA).

If you haven’t explored NBA, I would highly recommend you to take a glimpse at this ~30 mins long Trailhead Module.

Creating Flows & Recommendations for Various Emotions

Now, to keep things simple, we will create two Recommendations –

  1. What should the Support Rep. do when the Customer is Happy
  2. What should the Support Rep. do when the Customer is Sad

Even though we have 5 different emotions that will be analyzed by Indico, we will map – Anger, Fear and Sadness to “Sad” and Joy and Surprise to “Happy” (look at the Formula in figure 10).

This means that we will be creating 2 Recommendation records in Salesforce – Sad & Happy. But even before creating the Recommendations, you need to create two Active Flows.

Confused? Let’s revisit it. Now, how does Einstein Next Best Action work in Salesforce? The Next Best Action basically displays the Recommendation records (that we are yet to create) based on filters. On the Recommendation record, you need to specify – “How should the Recommendation be executed?” For example, if the customer is happy, prompt the Support Rep. to send an email. If the customer is sad/unhappy, prompt the Support Rep. to activate the warranty. So the Recommendation here is nothing but the prompt with the message i.e., “Please Send a Thank You Email” or “Activate Warranty” while the execution of the Recommendation is achieved through Flows.

So in essence, you would use a Flow to execute the Recommendation i.e., the process of sending the email or activating the warranty.

Like as I already mentioned, to keep things smooth, we will create 2 Flows that would check 2 checkboxes on the Case Record:

Note: In both the Flows shown above (Activated), ensure that you have a variable of type Text named as recordId created to store the Case Id as shown in figure 16.

Fig. 16

The next thing that you need to do is to create Recommendation records in Salesforce. So in order to do the same, click on the App Launcher and click on the Recommendations tab.

Create two Recommendation records as shown below:

Fig. 17

Fig. 18

Note: You can add Custom Fields to the Recommendation object just like any other object in Salesforce. In our use case, I have added a Custom Text Field called Category and filled it with the values Happy and Sad for the respective Recommendation records. This will allow me to query the Recommendation records easily while building the Strategies (in the next section).

Building the Strategies using the Next Best Action Strategy Builder

Now, we need to create 2 different Strategies that would query and show the Recommendations on the Case record based on the detected emotions.

In order to create Strategies, start typing “Next Best” in the Setup and then click on New Strategy.

Happy Customer Strategy

1. Drag a Load Element on to the canvas.

2. Specify the Conditions as shown in figure SB 1.1.

3. Save the strategy.

Sad Customer Strategy

1. Drag a Load Element on to the canvas.

2. Specify the Conditions as shown in figure SB 2.1.

3. Save the strategy.

Adding Einstein Next Best Action to the Record Page

Now, edit the Case Record Page and add 2 Einstein Next Best Action components and configure them like as shown below –

Summary: Lights, Camera, Action!

Voila! Let’s give it a whirl.


This blog has taught you how to “show Recommendations or the Next Best Action” to your support users using Einstein Next Best Action, integrated with emotion analysis.

I’ve also proved that you can accomplish complex implementations these days without actually writing Apex anymore, thanks to the amazing point-and-click features available today.

The Author

Shruti Sridharan

is a Senior Salesforce Developer. She is an Einstein Champion and a speaker at IEEE CSI Symposiums and Official SF APAC Webinars. She leads the WIT UG & blogs @shrutisridharan


    Rati Bhanot
    March 17, 2020 10:49 am
    Thanks for introducing us with the fresh concept i.e emotion analysis. The world is moving through personalization which means bring back the human touch.

Leave a Reply