Intro to the Bot Framework with Dynamics 365

Jordan Hohepa, 16 January 2017

Since Microsoft’s Build 2016 Conference there has been a huge buzz around Artificial Intelligence Bots and Microsoft’s Bot Framework for developers, and recently I have been diving into the discovery and development of these bots for different platform. Bots aren’t anything new, they’ve been around for years performing simple, repetitive tasks, but with the introduction of Microsoft’s Developer Framework developers can use a single API to developer a bot which connects and talks to users through many different channels. A quick example of a bot which Microsoft had created was a Pizza bot, in which users could message via skype to order pizza. By messaging this bot, a user could customize their pizza before having it delivered without the need to talk to another person.

At the moment, using the Developer Portal, you are able to connect your bot to many popular social services, including Facebook Messenger, Slack, Skype and Kik. With the increase in activity on social media and instant messaging the opportunity for bots is increasing tremendously and the only thing limiting the bots’ functionality is the imagination of the developer. This blog won’t be focused on the steps towards creating a bot, as there are many blogs that currently exist which do, but will instead be used to show simple examples of some of the things the bot framework can do. This blog will only show examples of interactions with bots via Facebook Messenger and Skype.

image

The first bot I built using this framework was a very simple bot which replied to a user with a question, and when the user provided an answer would either confirm if the user was correct or provide the user with the correct answer.

The conversation with this bot can be seen in the screenshots above. Now, this isn’t anything fancy or complex, so for the next bot I decided to build a profile based on what the user would input. This bot was able to hold a longer conversation with a user as it collected personal information about them to generate a profile. As you can see in the screenshots below, a user would only be typing a single word or tapping a button to reply, keeping the profile building as quick and painless as possible. Prior to the completion of the profile the user is shown all the information they have entered and given the ability to change their details one last time. This another was straightforward and simple example, but with a bit of creativity you can see how something like this can be applied to a much larger situation. For the next part of this blog I will be using the profile builder I’ve just talked about to create a new contact within Dynamics CRM.

image

Before starting this contact creator Bot, I had already gone into Dynamics CRM and created two custom entities which I used to hold information between Bots and Contacts. The first custom entity was a “Bot” entity, which held the name of a bot and each of its unique Id’s, ex Facebook specific ID. The second custom entity created was a “Bot Connection” entity, which was used to hold the information between a Contact and a Bot.

A few examples of the information this entity could hold would be the type of connection, ex. Skype, the Contacts unique id created for the specific channel and the Bot and Contact records which are connected. The example below shows the conversation between a User starting a new conversation with this Bot via Facebook Messenger. As shown in the example the conversation between the User and the Bot lead to the User deciding to create a new Contact within Dynamics 365. The conversation then follows a profile builder, like the one shown earlier and ends with a new contact in Dynamics CRM is created. After the Contact is created a new Bot Connection is also created between the new Contact and the Bot, storing the user’s details for this channel in Dynamics 365 so that the user doesn’t need to connect to CRM every time they talk to the Bot. Anything further than this is beyond the scope of this blog but as stated earlier with a bit of imagination you can see how beneficial these bots can be.

image