The Bot Agent Connector allows you to develop bots as Live Assist for Microsoft Dynamics 365 agents.
- Microsoft’s Bot Framework only supports bots using the Direct Line connector.
- These bots handle visitor chats as if they were agents and may transfer to another agent or skill group when you require.
This article assumes you are familiar with:
- The Microsoft Azure Bot Service
- How to register Bots against your Live Assist for Microsoft Dynamics 365 account by Creating a Direct Line Channel Connector.
- Accessing the Live Assist Demo Site
- How to Enable Chat on Your Site
- Live Assist Engagements
The bot in this article simply replies to any chat messages that the visitor sends to the bot.
The engagement targets a specific skill group, to isolate the bot from other agents in your organization. When the visitor sends transfer to MySkill, the bot transfers the chat to the skill group with human agents in it.
Requirements
To produce Bots as Agents you need the following:
- A Live Assist for Microsoft Dynamics 365 Enhanced License.
Each bot can handle 3 concurrent chats for each Live Assist license allocated. - A Microsoft Azure Subscription, with access to the Azure Bot Service.
Register for a free trial.
Important: This article demonstrates Microsoft's Web App Bot. If you are deploying a Function Bot, the surrounding code samples may need alteration, but considered out of scope.
Configuring an Engagement
To prevent chat bots mixing with your human agents you configure your engagements for chat bots, with their own skill group.
Creating a Web App Bot
Microsoft provides guidelines for producing a Web App Bot.
See:
Apply Live Assist Code
Where your bot receives a visitor message via the Direct Line Channel Data. You must:
- Check the message begins with the String "transfer to "
- Create a Live Assist Channel Data object
- Post the Channel Data back to Live Assist to initiate the transfer
The following code provides an example:
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
string TRANSFER_MESSAGE = "transfer to ";
if (turnContext.Activity.Type == ActivityTypes.Message)
{
if (turnContext.Activity.ChannelId == "directline")
{
var laChannelData = turnContext.Activity.GetChannelData<LiveAssistChannelData>();
switch (laChannelData.Type)
{
case "visitorMessage":
if (turnContext.Activity.Text.StartsWith(TRANSFER_MESSAGE))
{
var reply = turnContext.Activity.CreateReply();
var transferTo = turnContext.Activity.Text.Substring(TRANSFER_MESSAGE.Length);
reply.ChannelData = new LiveAssistChannelData()
{
Type = "transfer",
Skill = transferTo
};
reply.Text = "Transferring to " + transferTo;
await turnContext.SendActivityAsync(reply);
}
break;
default:
await turnContext.SendActivityAsync("This is not a Live Assist message " + laChannelData.Type);
break;
}
}
....
The LiveAssistChannelData object is a JSON structure you define:
public class LiveAssistChannelData
{
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
public string Type { get; set; }
[JsonProperty("skill", NullValueHandling = NullValueHandling.Ignore)]
public string Skill { get; set; }
}
See Also:
- Bot Agent Connector—API for a full list of Live Assist Channel Data types.
- The Agent Enabler API documents provide a full list of Channel Data objects.
Creating a Direct Line Channel Connector
See: Creating a Direct Line Channel Connector
Testing your the Bot
Your bot is now ready to test with your Live Assist for Microsoft Dynamics 365 engagement.
You can use the trial engagement, if you do not create a new one:
- The Visitor begins the chat:
- When the User enters: "transfer to MySkill", the chat is routes to the MySkill Group and an agent Agent answers it:
Debugging Web App Bots
There are numerous ways to debug your bot application.
See the following Microsoft documentation:
- Diagnosing runtime issues with the Failed Request Traces option.
See:
https://docs.microsoft.com/en-us/azure/app-service/web-sites-enable-diagnostic-log - The Kudu Console also provides access to the file system where logs are written.