Bot Agent Connector - Quickstart Guide
The Bot Agent Connector allows you to configure bots to act as Live Assist for Dynamics 365 agents. At the moment, only bots from Microsoft’s Bot Framework (using the Direct Line connector) are supported.
This guide aims to give step by step instructions on how to create a very simple bot from scratch (In Microsoft’s Bot Framework) and integrate it into Live Assist for Dynamics 365. We will use the Node.js sample but you will get the option to select .NET if you prefer (although that will not be covered here).
Live Assist for Dynamics 365 (with at least one available licence)
Microsoft Azure Subscription - to allow you to use the Azure Bot Service. If you do not have a subscription, you can register for a free trial.
Microsoft provides a tutorial for setting up a Bot Service: Create a bot with Bot Service. We have used this guide to create a NodeJS Bot, using a Consumption Plan. Our bot was titled: botechdemo.
Here are the additional steps creating the NodeJS Bot:
- Select the NodeJS option, Basic and read the terms, privacy statement and code of conduct. If you agree to these select the checkbox and press the create bot button.
- Once the bot has been created you should see the code for a file called index.js in your browser. Take the code sample below and replace the contents of this file with it.
- The screenshot below shows the differences between the snippet and the default bot.
The changes do two things:
Messages sent by the consumer are checked for the pattern transfer to x. If a message in this format is found, then a transfer is requested to the user with name x. The message source event type is also checked. This attribute describes various types of messages which can be received in certain situations. See the comments for what each message type relates to.
After making the code changes, click Save.
Building the Bot on .NET
To force a rebuild of the bot dialog, run the following:
- Open the console:
- Run the command msbuild:
Set up the Direct Line Connection
Now that the bot has been created, you will need to setup a Direct Line connection in order to get it to function through Live Assist for Dynamics 365.
- On the page that loads after the bot was created, click on the channels button.
- Select the Direct Line icon from the add a channel menu.
Select the show button next to the first secret key and copy it. Also ensure you tick the "High Speed Storage" option and hen press the Done button.
Add the bot in Live Assist for Dynamics 365
Once you have a Direct Line key, you can add the bot to LIve Assist for Dynamics 365.
- Visit the admin portal for the Organization you would like to add the bot for. (This link is different for different organizations - You can find it in the Welcome email you received when setting up Live Assist for Dynamics 365. Once logged in, select Users -> Bots.
- Select Add on the next page
- Give your Bot a name, select the number of licences the bot will use and then paste the Direct Line secret key copied earlier into the Connection Key box. Press Save.
You can specify how many licenses to assign to this bot, with each licence enabling the bot to handle up to three concurrent chats. The number of licenses option specifies how many licenses a particular bot will use. For example if a bot is configured to take five licenses, it can be involved with up to fifteen chats at any one time. The bot can be involved with chats equalling three times the number of licences it is allocated at any one time. By “involved with” we mean how many chats the bot can be sending and receiving messages in at once. If the bot escalates the chat to a human agent, it is then free to take another chat.
You may want to set up particular engagements which your configured bots will answer chats for. You can do this within Engagement portal - you can access this from the Live Assist for Dynamics 365 admin portal under Links -> Engagement Portal.
You should now have a Bot in Microsoft’s Bot framework which has been added to Live Assist for Dynamics 365. The following steps will tell you how to start a chat which should get answered by your Bot.
NB. In order to properly test the transfer functionality, you need to communicate with the bot via Live Assist (engagement or demo site) and not the azure web chat client channel.
This example assumes that you haven’t got custom engagement settings in place which will stop the chat from being answered by your bot.
If you are testing this on a live system please be aware that the bot will answer any chats that are started. In this case you may want to configure your bot to have a certain skill and set up a new engagement that routes to this skill.
Log into Dynamics 365.
Click on the down arrow next to service, select service and then Live Assist Administrator
In a new tab the CafeX admin portal should have opened (you may need to allow popups if you can’t see the tab). Click on the Getting Started link at the top right of the page.
On the getting started page that appears, click on the next arrow twice.
Then click on the Demo Site button to launch the demo site.
On the demo site, click on the Live Chat button to start a chat.
Your bot should answer the chat. You can type messages which the bot will repeat.
This walkthrough shows you how to create a basic bot and get it working in Live Assist for Dynamics 365 with the bot agent connector. It can be used as the starting point for a production bot, in which case you will probably want to manage the source code outside of the Azure portal.
If you open your bot in the Azure portal and select build, you should see an option to configure continuous integration. You can follow this guide to manage your source code how you choose.
Microsoft also offer extensive bot framework documentation.
Please see also the Bot Agent Connector API Docs