CRM Chat Bot: Part 3 – Development Deep Dive + Integration To Dynamics CRM

In the part 2 of the series, we have discussed on the concept of how the Bot Framework library is used to assist us building conversational bot. As promised in the previous post, I’m going to share the source code on how the bot framework can be integrated with Dynamics CRM.

The Story

Now, to build a conversational bot, it will begin with the use case of the bot. In my example, I’m going to use an imaginary  car dealer with this simple “User Story” from Scrum principle: “As a customer, I want to be able chat and let the company know that I want to test drive a car, so that I can make an informed decision when I’m buying the car”.

The Implementation

In the previous post, we have discussed the concept of Dialog, Form Flow and Luis Dialog. Now in this post, I will show on how these concept can be applied.

In general I’m creating the TestDriveDetail class to contain the test drive request detail:

Notice that all classes that will be used in Bot Framework will need to be decorated with [Serializable].

And a simple helper class to create the record to CRM.

Now, I’ll give the example of the simple implementation with the 3 different techniques (Dialog, Form Flow and Luis Dialog).

Sample #1: Simple Dialog

DialogBot.gif

The sample dialog is a series of prompt and at the end of the process it the store the information in CRM Online. Below is sample code of the Dialog, how the chain of prompts are created and at the end it is storing the record in CRM.

Sample #2: Form Flow

FormFlowBot.gif

As you can see at the above screen, the form flow is automatically generate the questions with the pre-defined options. Below is the source code of Form Flow implementation:

To initiate the Form Flow from message controller:

Sample #3: Luis Dialog

Now, we have seen how Dialog and Form Flow is getting the simple conversation started. However, if you might notice, the bot can only understand predefined keywords or options. (In Dialog, it is hard-coded to find “Test Drive” and in FormFlow it is directly asking the detail).

To overcome this, Microsoft has come up with a really cool Language Understanding Intelligent Service, a.k.a LUIS. In this post, I’m not going to describe in detail on how to setup LUIS model (will do next time), but I would like to introducing its capability that is able to predict/interpret the intent of the user. For this sample, I’ve prepared the following LUIS model:

luismodel

This model is configured to be able to interpret the intent of the user (Greeting, Test Drive, Ending Conversation, Brochure Request, None).

LuisBot.gif

Now, below is the source code on how the Luis Dialog is built.

That’s all for the sample codes! I hope this helps. For the code repository, feel free to have a look at github repo: https://github.com/andz88/CrmChatBot.

Stay tuned for the next part of this series: Deployment.

 

Advertisements

2 thoughts on “CRM Chat Bot: Part 3 – Development Deep Dive + Integration To Dynamics CRM

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s