Azure, Cognitive Services, Dynamics 365, Dynamics CRM

Get Sentiment score for D365 Text via LogicApps or Flow

Introduction

In Dynamics 365, we often record customer feedback in the system . The content can be of both positive or negative.

Feedback can be recorded in numerous places such as using the feedback entity or as an Activity.  As a customer record grows in the CRM system there will be multiple activity or feedback records created which can make it hard to identify the positives from the negatives. This will also make it hard for the Customer Service Representative to identify if the customer is a happy customer or an unhappy customer , so that proactive measures can be taken to win back the customer. So, what if there is a way to easily identify the positive and negative feedback and determine if the customer is a happy, sad or neutral .

I was recently going through the list of Cognitive services offered by Azure and stumbled upon an interesting service called the Text Analytics Service.

What the service does is that, if I pass a bunch of text to the Analytics Service it will provide me with the sentiment score. The higher the sentiment score it is a positive sentiment (positive feedback) or lower the sentiment it is a negative sentiment (negative feedback). You can try a demo of this service via this URL

Now, how can we connect this service to Dynamics 365 so that it can look at the text in an Activity or a Feedback record and provide a sentiment? There are two answers.

  1.  You can write a plugin that passes the text to the analytics API every time a       record gets created in CRM.
  2.  If you are already using Azure Logic App Service or Flow, there is a connector where you   can pass the CRM data to the Text Analytics API.

Today in this article we are going to look at the 2nd option where we can pass the CRM data to the analytics API via Logic App Service (I will use Logic App Service for this example as Flow is very much the same ).

Note: This article only demonstrates the capability of passing the CRM data to the analytics API via flow or LogicApps. This not a full business solution.

Example

Determine Customer satisfaction using Subject  field content in the D365 Phone Call Activity entity. The customer satisfaction should be displayed in a visual format i.e. Smiley Face in the Activity record.

Steps

Below are the tasks we need to achieve for the solution to work

  1.  Created a LogicApps Service in Azure.
  2.  Generate a Cognitive Services API key.
  3.  Configure LogicApps Steps to connect the Cognitive Services.
  4.  Add some JavaScript to display the visual indicator for the satisfactory level.

Step 1 : Created a LogicApps Service in Azure.

  1. Navigate to the Azure Portal
  2. Search and Add the Logic App service.

Step 2: Create a Cognitive Services API key

  1. Navigate to the following URL and generate an API Key for the Text Analytics API
  2. Generated API key

Step 3: Configure LogicApps Steps to connect the Cognitive Services.

Configuring LogicApps Steps consists of 3 items

  1. Select a Trigger (e.g. when a record is created in D365)
  2. Passing Text from the Triggering entity to the Sentiment Analysis Engine
  3. Updating the Source Record with the Sentiment Score

 

  1. Navigate to LogicApps in Azure and create a blank logicapp.
  2. Select the Trigger as when a record created in Dynamics 365. At this point you will be prompt to provide the login details to the D365 instance.
  3. Select the Org Name of the D365 instance and select the type of record for which the trigger should occur. In my example I am selecting Phone Calls
  4. Once the D365 Instance and the Trigger stage is complete , create an Action and select “Text Analytics – Detect Sentiment ”

  5. Specify entity field that should be used for the sentiment detection. I am using the text on the Subject field on the Phone call entity.
  6. Once the Sentiment Step is complete we need to update the Source record from D365 with the Sentiment Score returned from the Text Analytics engine. For this I have created a custom field called “Analytics Score”.First, I have to provide a Record Identifier to retrieve the source record that needs to be updated.Next I have to provide the custom field we created before to store the Text analytics score.
  7. Once everything is configured. You can create a phone call record in the D365 with some text on the Subject field and the system will automatically pass that text to the Analytics API and retrieve the sentiment score. In my example I have used a visual (smiley face). What I have done here is, I have used a simple JavaScript to display the smiley faces based on sentiment score.As I mentioned at the beginning the purpose of this article is to show the capability that LogiApps Provide.  Hope this has helped you in your daily consulting work . If there are any questions please feel free to email or comment.Sahan Wijayasekera

 

 

Tagged , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

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