Having a business system that gives actionable insights is important, allowing staff to be able to take information and turn it into useful knowledge relevant to their goals and mission within the business. This mission often involves interacting with customers. In an era of self-service, it’s not all the time the interactions are outbound, and customer interactions can come through via portals, landing pages, surveys and completing feedback forms in any length of time that is not guaranteed. The interactions can result in a, broadly categorised, positive, negative or indifferent experience for the customer. Given not everything is always going so positively with customers, wouldn’t it be amazing to know the general sentiment a customer has from the currently related interactions? This way, users can be alerted if a customer’s average sentiment changes to negative, or before you contact a customer you know if a recent interaction has made them less than impressed, giving you the opportunity to change their impression for the better.

This post guides you through creating a Customer Sentiment solution within Dynamics 365 CE using the Azure Text Analytics API. It allows you to use have a single metric (Sentiment) from a Contact record, categorising if a customer has an average positive, negative and neutral sentiment. It also allows users to review the related ‘Sentiment’ records so they can follow up directly on what may have caused an overly negative or positive experience.
Based on configurable interactions e.g. a new email, new feedback, a new survey submission or any sort of trigger you require, the data is sent to the Azure Cognitive Services Text Analytics API where it analyses the Sentiment of the text or a collection of text and outputs a sentiment value.  The  Dynamics 365 CE solution then displays an average sentiment over the life-cycle of a Customer, available straight on the Contact page.

Some considerations and observations of the solution:

–>  The solution uses Microsoft Flow to send the HTTP request to the Text Analytics API service. Learn how to build this from a previous post here.

–>  The ‘Survey’ entity and component in the solution is a custom solution mock-up (Survey Entity with custom Question and Answer entities)

–>  You do need to use and have an active subscription of the Azure Cognitive Services – Text Analytics API

The solution walkthrough will be covered in three easy steps;

1. Creating the entity ‘Sentiment’ to hold the associated data (Note, your associated entities, eg Feedback, Email etc must all be related to a Contact to make association easier)

2. Creating a flow, per entity, to record the sentiment score associated with the Contact

3. Customising the Contact Form

The end goal of this solution is to be able to navigate to a Contact record and see an average Sentiment across all interactions, as seen in the screenshot below.

Creating the foundations

The contact record will be directly linked via a new, custom entity called ‘Sentiment’. The ‘Sentiment’ record within this example, contains the following fields shown in the table below.
Field Name
Field Type
Text (Required)
Sentiment Score
Sentiment Score
Body Response
Multi Line Text
Survey (Custom Entity)

Sentiment score is twice so we can see the original value for audit purposes.

Origin – A custom global option set which will be set based on what the ‘Sentiment’ record was created from e.g. an Email, a Feedback Record, a Case or a Survey. This can contain more or less depending on what you will be creating Sentiment records from, it doesn’t have to contain these values if your solution does not require them.

Custom Lookups (Case, Feedback. Email, Survey) – These lookups are linked to those records which are specified in the ‘Origin’ lookup and are links to the original entity for auditing purposes. There is a business rule which hides the other fields which the Sentiment is not related to based on the Origin lookup.

A screenshot of the ‘Sentiment’ entity is below;

Creating the related Flows

Create a Flow per entity type used in the ‘Orgin’ field. Each flow will be on create (or update) of your triggering record, such as a Case. It then retrieves the data from that record (or child records) and sends a single HTTP request to the Text Analytics API service via the ‘HTTP Action’ in Flow. The final action in the Flow is the creation a new ‘Sentiment’ record and the population of the fields with the data from the Cognitive Service API output.
The recent posts below will be of help when creating these flows:
I’ve added some examples below on how to create a simple Flow which uses the standard ‘Feedback’ entity data from the ‘Comments’ field. The second example utilises a custom ‘Survey’ entity which iterates upon related Answers.

1. Create the trigger (from Dynamics 365) – The Feedback trigger is the ‘Creation’ of a Feedback record.

2. Create the HTTP Request, building the request based on the details from the Cognitive Service API (an example can be seen in the screenshot below)

3. Parse the JSON response using the ‘Parse JSON’ action

4. Create a new Sentiment record within Dynamics 365, ensuring to add the Contact lookup, setting the Origin and the related record e.g. Feedback record

It is important in the ‘Create a new record’ block where the ‘Sentiment’ entity is created, that the Contact, original triggering record (in this case, the ‘Feedback’ entity) and the ‘Origin Label’ field are set appropriately. This can be seen in the screenshot below.

The more complicated ‘Survey’ Flow example is below. Note this example you have to utilise this technique which obtains data from related child entities of the Survey (answers) and creates a variable that is passed into the HTTP request body.

Customise the Contact Form and create the Business Rules

The Contact Form needs to be customised to include;

1. A rollup field of related Sentiment (Contact) records which provide an Average of the related records

2. A new field, called ‘Sentiment Status’ which is linked to a Business Rule, and operates on the roll-up field value. This includes thresholds such as 0-3 = Negative 4-7 = Neutral and higher is Positive.

The roll-up field is fairly simple with nothing complex involved – state the related entity (Sentiments) and the single line that we need to display is an ‘Average of the Sentiment’ field. A screenshot of the definition is included below.

In the screenshot below, These were added in a new section along with a subgrid of related records. The subgrid will allow the user to see which sentiments were created recently and quickly analyse, by customising the view, the sentiment score, the origin and when it was created. They can click into the record to quickly look into the original record should they need to.
These fields can also be added to the headers and also in dashboards and views as appropriate. Even taking it further and adding custom icons in views could be useful for use at-a-glance.

To Summarise..

The components needed to make this solution are;

1. Azure subscription with the Cognitive Services Text Analytics API Service

2. New Sentiment Entity in Dynamics 365

3. A Flow per related trigger entity (between 1 and n, depending on how many trigger entities you have)

4. Customise the Contact Form with the addition of two new fields and a subgrid

5. Two Business Rules (One to only display the related origin lookup field on the Sentiment form, One to set the Sentiment Status threshold value) – Not essential to the solution but make it much more automated and visually appealing.

I hope this has helped to see how a solution that gives an overall sentiment ‘view’ of a customer and how they are experiencing an organisations customer experience can be made visible within Dynamics 365 CE. If you have any questions, please leave them in the comments below and I’ll do my best to help.