Dynamics CRM meets Machine Learning – Final


Welcome to the final post of this Dynamics CRM meets Machine Learning series where we have been discussing about using Machine Learning (ML) to interpret customer happiness by using certain cues and behaviour points based on Dynamics CRM data. If you have been following all along, you might notice that now the only remaining piece of this jigsaw puzzle is the usage of the ML insights i.e. the score of the email, inside Dynamics CRM.


We have already seen the ML engine and how CRM can connect to the ML web service that calculates the score of the email based on its content. Now we will focus on how to show the Happiness Index on the Contact record that will tell us about the level of satisfaction of a customer when we open their record.


Dynamics CRM customisations

We will be adding the following fields into CRM

Entity Field Purpose
Email sentiment This field will store the sentiment calculated by the Online Azure Machine Learning Web Service. Its value will either be 0 – Unhappy email or 4- Happy email
Contact Total Emails Total emails received from this contact
  Average Sentiment Score Average ML sentiment score based on all emails
  Happiness Index If more than 2 emails have been received then average sentiment score, otherwise 2


I have used rollup and calculated fields that rollup the sentiment score from emails over to the contact record.


Displaying Happiness Index

The happiness index is shown on the Contact form and an emoticon is displayed based on the score e.g. in the example below the Index score is 2.4 which is on the happier side, so a happy face is shown. The below screen also shows various emails based on which the score for Jim Glynn was calculated by the ML web service.



Now let us look at a slightly unhappy customer Patrick Sands. You can look at his emails on the right to determine why is he unhappy. The scores in the Sentiment column have purely been calculated by the ML web service.



Script to show emoticons

I think these graphics look cool and add a face value to your customers. If you are curious to know more about how I displayed them, below is the script. Basically there is a html page added as a web resource and I replace the image based on the score




 <meta charset="utf-8">



   2:  function onPageLoad() 

   3: {

   4:  var happIndexString = window.parent.Xrm.Page.data.entity.attributes.get("manny_happinessindex").getValue();


   6: if (happIndexString != null) 

   7: { 

   8: var happIndex = parseFloat(happIndexString); 

   9: if (happIndex <= 1) 

  10: { 

  11: this.imgIndex.src = "manny_1.png"; 

  12: } 

  13: else if (happIndex > 1 && happIndex <= 2) 

  14: { 

  15: this.imgIndex.src = "manny_2.png"; 

  16: } 

  17: else if (happIndex > 2 && happIndex <= 3) 

  18: {


  20: this.imgIndex.src = "manny_3.png"; 

  21: }


  23: else if (happIndex > 3 && happIndex <= 4) 

  24: { 

  25: this.imgIndex.src = "manny_4.png"; 

  26: }


  28: }

  29:  }










style="margin: 0px; word-wrap: break-word;" onload="onPageLoad()">

 <img id="imgIndex" name="imgIndex" src="manny_2.png" border="0">




And below is the entire solution that shows plumbing on the CRM side of the fence




So there you have it, a simple solution that works end to end by consuming ML web service from within Dynamics CRM that gives you some insight into the satisfaction of your customers. The algorithm, that just uses body of the email, is indeed a simple one but it can be enhanced to take into account various other parameters and behaviour points that we have discussed in Part 2. This is just tip of the iceberg, there are lot of possibilities with Machine Learning.


Hope you enjoyed the series. Let me know if any comments or feedback.


2 thoughts on “Dynamics CRM meets Machine Learning – Final

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s