Previously I had written a blog which introduced the Microsoft Bot Framework. In that blog, I showed an example bot which connected Dynamics 365 with Facebook Messenger and Skype. This bot would simply ask the Facebook or Skype User a series of questions which would result in a Contact record being created in Dynamics 365. When this Contact is created, a record for the Custom Intersect Entity named the ‘Bot Connection’ is created which connects the Bot entity to this contact. This Intersect Entity contains information on the type of connection between the bot and the contact, including the contacts unique id and the channel the contact is connected to. This blog will give an example of one of the practical ways I have used a bot and hopefully spark up some simple ideas on how these types of bots can be used.
Recently I was tasked with developing a data migration for a large amount of data. I decided on developing a console application to handle this task. While developing this console application I ended up including logic which would connect to Dynamics 365 and retrieve my contact and bot information. The screenshot below shows the editable values I used to retrieve the Contact, Bot and Bot Connection. For simplicity, I kept it to these three settings.
The data migration itself was processing multiple entities, so when an entity had completely migrated its records I had recorded the entity name and the time it took to migrate. The console application would then combine this message with information from the Contact, Bot and Channel and pass this into the method below as a secret message. The direct line secret key which was also retrieved from Dynamics 365 and is passed into this method. The console application would send a message to Facebook if an entity had completed processing or if the data migration had crashed.
When the bot receives this direct line message it would send a message to the desired contact using Facebook Messenger with custom logic. To be available to receive these notifications I made the User have to confirm that they wanted to “Allow notifications”. Then after a few minutes I received my first notification. The screenshot below shows an example of a message received from the console application.