Supervising bot conversations
One advanced concept for bots built using the Microsoft Bot Framework is handing over conversations to human supervisors (or agents). For instance when the bot is no longer able to automatically process a request, or if the end-user of the bot is frustrated/stumped and wants some assistance.
There is already some great content out there on this concept which goes into more detail on the user scenarios: https://docs.microsoft.com/en-us/bot-framework/bot-design-pattern-handoff-human. In addition, I've collated some resources and tips below in order to assist you.
First off, to understand the concept further, watch my colleague, Hannah Krager, give a great talk here: https://channel9.msdn.com/events/Build/2017/P4075
Assuming, you're still with me - it's time to get the code samples up and running:
A word of caution, the additional libraries to assist with this are in a state of heavy flux and provided as samples only. If you're ok with that, read on fellow bot developer <''>
Node.js
If you're a Node.js fan, you can start here: https://github.com/palindromed/Bot-HandOff and read an article by Lilian Kasem, one of the authors of it here: https://www.microsoft.com/reallifecode/2017/06/30/bot-to-human-handover-in-node-js/. However, given the title of this article, I'm looking at the C# SDK.
C# Yay!
Now, if you prefer C#, it's a little bit more trickier.
However, my colleague Tomi Paananen has created a great library to help available here: https://github.com/tompaana/intermediator-bot-sample. You can also read his accompanying blog post on this: http://tomipaananen.azurewebsites.net/?p=1851.
Again, did I mention these libraries are in a state of flux? I'll try and keep this post updated with changes For transparency, the video samples shown below are actually based off my fork here: https://github.com/daltskin/intermediator-bot-sample (pull request outstanding).
In addition, there are a few moving parts to getting this up and running depending which scenario you want you agents/supervisors to use. When debugging this locally, you'll end up with quite a few windows open as you need to run a number of things.
Scenario 1: Channel <-> channel
This is the most straight forward, all you'll need is your bot running and then use different channels to simulate different users. In the video I use a combination of Skype, Webchat and Slack. I then use Slack as the supervisor channel by running: "agent watch" * This begins listening for any requests for assistance to the bot - instigated by any use of the term "human" from the end-user.
*If you're using https://github.com/tompaana/intermediator-bot-sample the commands are slightly different, you'll need to run "agent add aggregation"
Scenario 2: Channel <-> call center (Agent UI)
If you're looking for the Agent UI scenario you'll also need the Webchat agent written by Bill Barnes here: https://github.com/billba/agent as well as the intermediator C# sample bot running locally (again follow the Readme.md to ensure you're endpoints are correctly configured with ngrok/bot framework portal settings).
Then modify the Agent/index.ts as per the Readme.md (your bot endpoint for the AgentController.api and the WebChat token - which you get from the dev.botframework.com portal for your bot):
To get it to build I needed to run the following commands:
npm install typescript@2.0.10 npm run build npm run start
The Agent will then poll against your bot endpoint eg: http://803705b8.ngrok.io/api/agent/1 - looking to see if it needs to spin up any webchat controls for any user requesting a "human" to talk to. The nice feature of this scenario is that a single agent can manage multiple conversations at a time. The video below shows what this looks like to setup and run with a a user requesting assistance on Skype: