Dynamics CRM meets Machine Learning – Part 2

Through the previous posts on this Dynamics CRM meets Machine Learning series, so far we have covered that how Machine Learning (referred as ML hereafter), when actively involved with Dynamics CRM can help us determining and maintaining customer happiness. The business problem has been defined with a proposed architecture to achieve this.


Dynamics CRM behaviour points

The definition of a happy customer varies from one organisation to another.

  For a customer service focussed organisation, it can be determined by

  • Average number of hours/days taken to resolve a case
  • Feedback ratings provided by the customers on cases and the customer reps
  • Average wait time spent by the customer over phone/chat before being put through to the support team
  • Tone of the message within an email or phone call

For a sales focussed organisation, it can be based on

  • Number of quotes declined by the customer
  • Number of revisions to the sales order or the contract document
  • Number of times sales staff did not respond to customer meetings or phone calls
  • Number of irate or happy messages received over company’s Facebook portal

Other advanced behaviour points can also be taken into consideration. For example, if a customer did not renew the contract, as a post-mortem analysis it can be checked

  • if they recently had any tickets that were open for too long
  • if they recently had their request for loyalty discount denied
  • if they recently emailed about the sales manager not returning their phone calls

Of course the system can only use the information which has been recorded, as its yardstick for customer satisfaction. It won’t know that the customer is actually unhappy because last month you missed inviting them to your annual company party, or if your support rep chose not to record a feedback from the customer regarding a missed shipment. It’s not there yet .. !!

Now all these data points discussed above are part of the equation that can be used to determine a particular behaviour of interest. This is where a data scientist’s role pitches in, to collect the most fruitful behaviour points that closely correlate to the behaviour being measured.

Aggregated Happiness Index

Once the behaviour points have been agreed upon with the customer, they can be factored into the Happiness Index calculation. Below is an example of how it may look like in a customer scenario.


As you can notice, as soon as a case is resolved or a quote is revised (or data from a behaviour point is available), we get its score by calling the appropriate ML service and update the aggregated happiness index score onto the contact record. A common plugin or workflow library can be used and its handler can be added to all the events pertaining to behaviour points e.g. quote revise event, case resolve event, etc..


Use behaviour points to train the ML engine

Over to the ML module now, we will use supervised learning to train our engine to interpret the behaviour points. For the simplicity of this series, I will use just the content of the email message as the only factor in determining the Happiness Index. After all the focus of the series is on an end-to-end integration.

Let me explain in simple terms what supervised learning means in our context

  • You choose two classes (categories): happy (4) and unhappy (0)
  • Then you feed training data (e.g. thousands of email messages) already classified as either in happy class or unhappy class into the engine
  • Training process runs and it uses techniques like feature hashing to interpret data and find commonality between traits of data in either class

Below are some of these traits that can be used

Behaviour point Happy trait Unhappy trait
Case resolution time Case resolution time within SLA Case resolution time  double than expected SLA
Quote revisions Within accepted threshold (smooth deal) too many revisions (going back and forth)
Words in the email good job
doing well
why are you not replying?


Once trained, the engine can do scoring with a certain probability e.g. given a sentence it can tell you if it is 0 or 4 and how much certain it is e.g. engine will say I’m 85% certain that You are replying late is a unhappy message. It will return the result 0 and probability 0.85 for this input.


ML engine

Below is a screenshot of the experiment that I have used for my email message binary classifier. I would not go into the detail and setup of each step but basically it takes message body as input and returns a score: (0) for unhappy and (4) for happy. Only two states – 0 or 4.



Next week we will cover how to deploy this Machine Learning Service and consume it from within Dynamics CRM.

Thanks for reading and comments are welcome.

Dynamics CRM meets Machine Learning – Part 1 : The Business Problem & Solution Architecture

Continuing the journey of our Dynamics CRM and Machine Learning series, in this post I will define the business problem we are trying to solve using Machine Learning (referred as ML hereafter) and how the solution will work. You can read the premier that introduces this blog series if you haven’t already.


The Business Problem

When an organisation implements a CRM solution, the most basic goal they try to accomplish is to manage the interactions and dealings they have with their customers through this CRM solution.

Any organisation, Any CRM – customer interactions are always tracked inside CRM.

Interactions build relationships. And they damage them too !!

Take email for example – the most trustworthy and traceable medium of a customer interaction.

Every deal starts with an email and is sealed with an email (sign-off), appreciations are made using emails so are the complaints. Emails are the mirror through which CRM users see their customers .

Think about it – when a new sales exec or a customer rep joins your organisation and is about to deal with one of your existing clients, where do they go to find out what is this client up to ??


Guess where ??


Courtesy: funnyjunk


They go through all the recently exchanged emails pertaining to the work they are about to start. So that they can take it forward from where it was left by the last rep.


Emails –  A dimension of Customer Satisfaction

So I hope by now we have established that it is  an undeniable fact, that emails (and their content) is the most important asset of any CRM system. An email from your customer with an appreciative tone instils confidence and hope inside you.

Whereas an email marred with apprehension and displeasure heralds  the ominous moves coming your way. 

But how does an organisation pick up on these early cues of a crackling relationship so that it can be repaired before it’s too late ??

A solution could be to utilise existing emails from the customers and determining satisfaction based on their content.  We can assign a score to every email based on the gist of the message and its indicative tone. Then a statistical measure can be applied up the chain, to rollup the score over to the customer record.


Customer Happiness Index

So that score which will rollup to the customer record is the magic number that I will refer in this post as the Customer Happiness Index

More pleasing emails from the customer, higher the index – happy customer

More displeasing emails from the customer, lower the index – unhappy customer


Simple … Lets roll.


There, often are thousands, if not millions emails in any CRM system. So let us not even contemplate doing this work manually.

After all we have better things to do in life than judging the content of emails (especially if you, like myself, happen to be living in sunny country like Australia) .

Let us use Machine Learning Intelligence to our advantage.


The Score

Customer Happiness Index will range from 0 to 4

0 – Extremely Dissatisfied

4 – Extremely Happy


An indicator will appear on every contact record in Dynamics CRM  that will show how happy they are

Dynamics CRM – Happiness Indicator 1 2 3 4
Index Less than 1 1 to 2 2 to 3 3 to 4
Interpretation Dissatisfied Neutral Satisfied Extremely Happy


Solution Architecture

A picture is worth a thousand words

To the wisdom of this famous saying, I will leave you with a picture of proceedings on the way. The design is simple and self explanatory from the captions, we’ll dig into the innards in the next post



Dynamics CRM: Use Machine Learning to calculate Happiness Index

Right now there is a  fantastic opportunity for the CRM systems to get intelligent by leveraging the smart capabilities offered by Machine Learning (referred as ML hereafter). As the markets around the world become increasingly competitive, I reckon it will be the smartness of their CRM systems that will keep certain companies ahead of others. CRM 2016 is out and Microsoft is working hard to put intelligence into their flagship business solution by integrating Azure Machine Learning offerings with Dynamics CRM.


What is Machine Learning

In my opinion, the key notion of machine learning is to be able to make sense out of the data, a sense that can drive timely business decisions. More and more business are adopting ML in a bid to strengthen their customer base and to stay ahead of their competitors.


How does ML work. Is it Magic?


Courtesy: ironarchive

Every magic has a reasoning behind it and ML is no exception. The ML Systems do it by classifying data, learning from past trends, getting intelligent over time and eventually by making predictions based on scoring results achieved after massive number crunching.

The purpose of this post is not to talk about ML and its concepts but to rather show it in action especially its integration with Dynamics CRM. There are numerous resources on the internet that you can leverage to understand ML.


Take control over Machine Learning

You may already be aware of certain functionalities where Dynamics CRM is already using ML capabilities like matching KBs to cases, recommending products to cross-sell and generating sentiment analysis reports from within Social Listening. When I look at these solutions, their core ML engines are not exposed to users, they are not customisable. You input data (from CRM), call the ML service and get output, but you have no control over how that output is generated.

What if a customer wants full control of the ML engine:

  • they want to choose what algorithm to use
  • they want to train the system with their own data
  • their data scientists want to define the parameters

so that the outcome of the integration is more personalised (and accurate).

These are the objectives that I will attempt to achieve through this blog series, absolute control over the ML engine.


Sounds exciting ??

download (1)

Courtesy: hungrysojourner


Lets begin !!



I will put together a solution that will show how we can integrate Dynamics CRM 2016 with Azure Machine Learning Services. Throughout the series, the focus will be poised more towards an end-to-end working integration, rather than the perfection of the ML algorithms and accuracy of predictions. In other words, in this first cut we will have a solution that works; may not be a perfect solution.  You however will have full opportunity to improve it  i.e. you can choose a better algorithm, better training model to improve the ML capabilities.


Below is the series

Dynamics CRM: Use Machine Learning to calculate Happiness Index

Part 1 – The Business Problem & Solution Architecture

Part 2 – Training the Machine Learning model

Part 3 – Deploying the Machine Learning solution

Final – Customising CRM and Integration

Knowledge Article Vs KB Record

Dynamics CRM, after its recent association to Parature, has come up with a new entity called Knowledge Base Record. The name of this new entity is very similar to the legacy Knowledge Article entity which has always existed in Dynamics CRM for its native knowledge management functionality. Sometimes these similar names can cause confusion and we may end up linking the wrong entity/relationship. This post will help you in distinguishing and locating each of these entities.


Let us take the example of Case entity. If you explore the Case entity, you will see that it is provisioned to link to both the Native Knowledge Base and Parature.

Relationship Name   Linking Entity Type Purpose
knowledgearticle_incidents KnowledgeArticle Incident 1  to Many For linking a Native KB article to a case
incidentknowledgebaserecord KB Record Many to Many For linking Parature KB articles to a case


Knowledge Articles are normally located in the middle composite grid, whereas KB Records are found under an associated view called Linked KB Articles

FieldOne Sky – Address Standardisation

Have been playing with FieldOne Sky, which is a Dynamics CRM 2016 Customer Service addon. One thing that caught my attention while starting to create Accounts was a popup that comes automatically while you are entering an address into an Account or a Contact record in Dynamics CRM, and presents you with the completed address.

Curious to know that from where was it coming from I tried to check the source and found that it is coming from one of the web resources that is a part of FieldOne solution.




Well the good thing is it provides you free of cost Address lookup and Autocomplete functionality as shown below.


Thanks Microsoft, keep the goodies coming !

CRM users who do not have a valid security role assigned

When a CRM implementation goes live the most important task is to get the users on board with their new Dynamics CRM system. CRM Admins ensure that proper security roles are assigned to every user so that they can log in without any issue. However, assignment of the security roles to the users is still a manual task and when you have hundreds of users, there is a possibility that some users may get missed.

CRM has a very useful view on the User entity called Users with no assigned security roles which does a pretty good job in quickly identifying those users who have a valid license but do not any security role.

But the situation becomes challenging when you have  blanket security roles e.g. ClickDimensions User or Xperido User that are assigned to every user and on top of that each user should have at least one CRM specific security role e.g. SalesPerson, Marketing Professional, etc.

How do you make sure that every user has at least one CRM security role on top of the blanket (or addin) security roles?

I would like to share a solution I have used to achieve this using FetchXml left outer join.

The prerequisite for this query is that you need to find out the GUIDs of the blanket security roles that you want to exclude from your search criteria.

e.g. the below query return all users who do not have any security role assigned to them excluding Xperido User and ClickDimensions User.


<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >

  <entity name="systemuser" >

    <attribute name="fullname" />

    <attribute name="internalemailaddress" />

    <order attribute="fullname" descending="false" />

    <filter type="and" >

      <condition attribute="isdisabled" operator="eq" value="0" />    

      <condition entityname="userrole" attribute="roleid" operator="null" />


    <link-entity name="systemuserroles" alias="userrole" from="systemuserid" to="systemuserid" link-type="outer" >

      <attribute name="roleid" />

      <filter type="and" >

        <condition attribute="roleid" operator="ne" value="{24EB9173-7C62-E511-80EA-C4346BC5A710}" /> <!--Xperido  -->

        <condition attribute="roleid" operator="ne" value="{26EC7898-1029-E411-934F-00155D00730E}" /> <!-- ClickDimensions -->





You can run this fetchXml  in XrmToolbox or save it as view (SavedQuery)

Diagnosing FieldOne Sky mobile app

FieldOne Sky, the MS CRM field solution, comes up with a free Windows app that you can use as an emulator/tester for the mobile functionality. In my opinion and after reading other users’ experiences on the web, the app is still getting mature and you *may* encounter a crash.


Courtesy: arquivogamer


When it crashes, the app simply vanishes from the console without any warning or error log file.

How do you know what caused the error, so that you have at least an opportunity to DIY a fix


So what do you?


After following some traces and doing random searches in the temporary files, I did hit upon the error log which is contains the actual error that caused the crash.


The mobile app maintains the error log in a file called crash.log (what an appropriate name Smile)

The file is present here: C:\Users\<loggedinUser>\AppData\Local\Packages\FieldOneSystemsLLC.FieldOneSkyMobile_xxxxxxx\LocalState\MobileCRM


Another important files that keep the execution log can be found here

C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_FieldOneSystemsL_<a big guid>\Report.wer (open this with notepad)


Happy diagnosing !!