• Home
  • Blog
  • About Me
  • Home
  • Blog
  • About Me
AI  ·  Dynamics 365  ·  Power Virtual Agents

Hand off a Virtual Agent Bot to a Omnichannel Chat

By Joe Gill  Published On 12th August 2019

I could not find any information on how to to hand off a Virtual Agent Bot to a live agent so I thought I would have a go at doing this. I previously did a post how to deploy a virtual agent bot to a CDS Portal here. I am going to modify this bot to allow the user to transition the conversation to a human agent. The results are not as seamless as I would have liked however I think this is acceptable considering we are working in a no code environment.

omni channel dynamics 365

There are three steps required to accomplish this

  1. Create an Omnichannel Chat Channel to accept the transferred bot conversations
  2. Create a page in the Portal to host the Omnichannel chat widget.
  3. Add the chat page url to the Virtual Agent Topic so the user the can transfer to an agent

Step 1: Creating dynamics 365 Omni channel

In the Omnichannel Administration App I created a chat widget called Bot Transfer to handle transfers from the Virtual Agent Bot. Saving the chat widget generates the Javascript code required to start a chat session. We will use that later to initiate the chat transfer.

Dynamics 365 Omnichannel Chat - Joe Gill - Virtual Agent Bot

Step 3: Create a page in the Portal to host the Omnichannel chat widget.

From the CDS Web Portal App I created a Web File called chat.html which is the page that will host the Omnichannel chat widget

Omnichannel Chat

I needed to add the Omnichannel chat snippet as an note attachment to this chat page file. The out of the box chat snippet prompts the user to click a button to start the chat. To avoid this I modified the snippet to start immediately by added in data-hide-chat-button=”true” and the Javascript below it to to start the chat immediately.

<script id="Microsoft_Omnichannel_LCWidget" src="https://oc-cdn-public-eur.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js" 
        data-app-id="e1de728f-c4c5-4397-b4b5-048edb8bf528" data-org-id="98315898-538e-4c55-93cf-b28f0afb1ee7" 
        data-org-url="https://org1fbee8a1-crm4.omnichannelengagementhub.com" 
        data-hide-chat-button="true">
window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
	Microsoft.Omnichannel.LiveChatWidget.SDK.startChat();
});
</script>

Step 3: Add chat page URL to Virtual Agent Topic

The final step is to edit your Bot’s topic to hand off to a live agent in Omnichannel. I edited the Escalate system topic and added a hyperlink to the CDS Portal page chat.html as shown.

dynamics 365 omnichannel - Editing Topic

Now if the Bot users triggers the escalate Topic they are prompted with a link they can click to start a session with a live agent. This will open up the chat page and the chat will immediately start.

Ideally it would be great if the hand over to the agent was in the same chat window. I can’t imagine that is possible are they are both hosted separately. I saw a Microsoft video somewhere that said the bot conversation history would be available to the chat agent when it gets handed off but I could not find a way to do it.There is a way to pass context data from the virtual bot to the Omnichannel but I have not tried tried that yet.


Create Power Apps Portal & Virtual Agent Bot
Previous Article
CDS Non-interactive accounts now need licences
Next Article