Copilot Studio [Sample Use Case]: Custom Copilot Handoff to D365 Customer Service

With Copilot Studio, we can configure our copilot to hand off conversations to live agents seamlessly and contextually. When your copilot hands off a conversation, it shares the full history of the conversation, and all variables collected in the interaction. Dynamics 365 Customer Service routes incoming escalations to the right queue, and a live agent can seamlessly resume the conversation.

With this context, a live agent that uses a connected engagement hub can be notified that a conversation requires a live agent, see the context of the prior conversation, and resume the conversation.

Use Case Scenario:

  • Custom Copilot that is embedded in a Custom Website/Portal. The Portal is configured in D365 Power Pages.
  • This Copilot can answer the user queries related to Customer Service implementation using External Website as Knowledge Source.
  • Once done, Customer needs to provide their Feedback.
  • The Customer Feedback with be processed by AI builder to perform Sentiment Analysis.
    • If the Feedback is Positive, then Copilot displays a Thank you message.
    • If the Feedback is Negative, then the chat will be handover to Live Agent in D365 Customer service for further actions.
  • Customers can also trigger the Chat with Live Agents anytime by prompting the Copilot to Transfer to Agent.

In this Use Case Scenario, we will be using the below tech stacks,

  1. Copilot Studio.
    • Knowledge Source- External Website.
    • Use Custom Prompts – Using AI Builder.
    • Trigger Customer Service Handoff.
  2. Dynamics 365 Customer Service.
    • Omnichannel Power Virtual Agent Extension.
    • Configure Queue, Workstream.
  3. Power Pages Custom Portal.

1. Copilot Studio – Building a Custom Copilot:

  • For this Demo, we are going to build a copilot with
    • External Website as Knowledge Source.
    • Custom Prompt to analyse the User Sentiment.
    • Custom Topic to hand-off the conversation to Live Agent.
    • Setting up Manual Authentication.
  • Create a New Copilot for this demo.
  • Enable the Generative AI mode
  • Next, we can Setup the Knowledge Source.
  • In this case we can just use the Microsoft documentation link for Customer Service Implementation.
  • Most important step, is to create a new topic to handle our Scenario.
  • After providing a proper description about the Topic, we can insert a Question node that gets the User Feedback as Input.
  • Next step is Creating a Custom Prompt using AI builder.
  • We are just going to use the Sentiment Analysis of text, when AI builder can return the response as Positive, Negative or Neutral based on Customer Feedback.
  • We will get the Output of the Custom prompt and store in a variable.
  • Now based on the Output value, we can add different conditional branches.
    • When Positive, we can just show the user a Thank you message.
    • When Negative, we can configure the Hand-off to Live Agent.

2. To Trigger Handoff to D365 Customer Service:

  • Below the message node, select the Add node icon , point to Topic Management, and select Transfer conversation.
  • Enter an optional private message to the live agent in the Transfer conversation node. This optional message can be useful if you have multiple topics with Transfer Conversation nodes.
  • These two steps will automatically transfer the chat to the live agent, which we can see Later below.

3. Setting up Manual Authentication:

  • To Enhance the security, we will go for using the Authenticate Manually option. You should either use None (or) Authenticate Manually.
  • You can refer to this link to understand more on how to Set up Authenticate Manually.
Copilot Studio: How to Configure Manual Authentication

4. Install Omnichannel Power Virtual Agent Extension:

  • To make the Handoff work as expected, we need to install an Extension.
  • Go to Power Platform Admin Centre -> Resources -> Dynamics 365 apps.
  • Check for the app – Omnichannel Power Virtual Agent extension.
  • Click on Get it now.
  • Select the Environment where D365 Customer Service is available.
  • Please make sure, our copilot also is built in this same Environment.
  • Once the Installation Starts, you will see the below message.
  • After few mins, the installation will be completed. Make sure the Status is Installed before proceeding.

5. Configure Handoff to Customer Service:

  • In the Copilot Studio, click on Channels tab.
  • We can see Dynamics 365 Customer Service option available.
  • Click on that, will open a side pane that will show the Status as Not connected.
  • All we must do, is just to click on Connect button in the bottom right.
  • Copilot will take few mins and automatically establish the connection with the D365 Environment.
  • Please make note that, the Copilot and Customer service should be present in the same Environment for the handoff to work properly
  • Click on View in Omnichannel.
  • To proceed with successfully performing the handover we need to do 2 actions:
    • Create a Queue
    • Create a Workstream
  • To Setup, Navigate to Customer Service admin center.
  • The App Customer Service admin center opens as shown below.
  • We will create a Queue and add the human agent as well as the Copilot that we have created to the queue.
  • Click on Queues from the left side pane.
  • From the Advanced queues section, click on Manage.
  • Click on New Queue.
  • Mention the Queue Name.
  • We can create a Messaging/Record/Voice queue. For this demo, we will create a messaging handover queue.
  • Specify the Group Number. Assigning a group number helps you organize your queues in the list view if there are multiple queues.
  • Click on Create to provision the queue.
  • Once the queue is created, it will take us to the newly created queue page. Click on Add Users to add the Human Agent as well as the Copilot to the Queue.
  • Select the human agent user as well as the Copilot agent instance and click on Add.
  • The queue setup is now done, and we will add this to a workstream as the conversation handovers will first come to the workstream and from there it is routed to different queues.
  • Now let’s create a Workstream. A workstream is nothing but a container to route, and assign work items. From the Workstreams tab in the left pane, click on New Workstream.
  • Specifying the workstream name, Type as Messaging and the channel type as Chat.
  • Select the work distribution mode as Push so that when a conversation comes, it is auto assigned to agents based on capacity and presence.
  • Next, we will just choose the Fallback Queue. So, let’s select choose existing and pick the User Feedback queue (that we created in the above step). Click on Create.
  • Once the workstream is created it will automatically take us to the newly created workstream where we can configure the chat. This Chat we will be using for interacting with the users. The Copilot interactions will now be hosted within this chatbot.
  • Click on Set up chat.
  • This will open up the popup where we can define the chat channel attributes like name and language and click on Next.
  • In the next page, we can define the look and feel of the chat bot widget that will host the Copilot conversations and the human agent handover. Click on Next.
  • We will retain the chat channel behavior parameters with default values and click on Next.
  • We will retain the user features with default values and click on Next.
  • Finally let’s click on Create channel to provision the chat channel.
  • Once the channel is created, it will take us to the chat channel section.
  • We can copy the Chat Widget Javascript code by clicking on the Copy.
  • This can later be embedded into the website or Power Pages which will allow the user to chat with the Copilot and initiate the handover to the agent as part of the escalation process.
  • We will for the time being go with the fallback queue that we have created.
  • This completes the configuration of the Omnichannel within the Customer Service admin center. We can now go ahead and use the chat widget which embeds the Copilot and handover logic within Power Pages.

6. Power Pages Portal:

  • For this demo, we have created a Power Pages portal using the existing available Template.
  • Click on the Edit button to Edit the Site.
  • The Power Pages maker window appear as shown below.
  • To Add the Live Chat Widget Script into the Power pages site, we can directly “Edit Code” on the maker screen.
  • Click on Edit code Will ask us permission to Edit the portal site inside the Visual Studio Code online. We don’t need to have a separate App version installed in our local system.
  • You can view the code of the Power pages portal into the Visual Studio Code.
  • Now we can copy the Live chat widget script.
  • Navigate to the Omnichannel Admin Center -> Open the Workstream that we recently created.
  • In the Chat Widget section, click on “Copy Live Chat Widget Script’.
  • The Script will look like below as shown.

<script id=”Microsoft_Omnichannel_LCWidget” src=”https://oc-cdn-public-apj.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js” data-app-id=”fca640db-4ac9-4ce7-891c-404780bb7cd3″ data-lcw-version=”prod” data-org-id=”bc6d10e7-3990-ef11-8a66-00224819bc81″ data-org-url=”https://m-bc6d10e7-3990-ef11-8a66-00224819bc81.as.omnichannelengagementhub.com”></script>

  • Now page the Script anywhere inside the Visual Studio code, without disturbing the existing components.
  • In my case, I have just created a Div for sidebar and then paste the script into it.
  • Once done, Click on Sync button to update the changes in to the Power Pages Portal.
  • Once done, the steps are completed. We have successfully configured the Copilot chatbot to handoff to the D365 Customer Service.

7. Test the Copilot:

  • Navigate to the Power Pages Portal.
  • We can see the Chat Widget available.
  • Click on the Widget will trigger the Copilot chat.
  • Since we have set up the Manual Authentication, Copilot asks for Login.
  • User needs to click on login and get the verification code.
  • Confirm the verification code , and the Copilot starts interacting as expected.
  • We can ask a Sample Question based on the Knowledge Source specified. In this case im just asking – How to view a Case Summary in Teams?
  • Copilot will be able to read the contents from External Site that we configured as Knowledge source and provides the Response as expected.
  • It also provides the Citation reference.
  • Now we can try asking the Copilot for Live Agent. Giving the prompt – Chat with Agent.
  • Copilot can understand that user needs to talk to Live agent and prepares for Handoff since we have already configured the Topic
  • Now we can open our Customer Service Workspace, and can see the chat request appearing in for the Agent.
  • Click on Accept to continue the chat.
  • The Communication panel opens on the Left side of the window, that give the access to the Chat with the Customer.
  • The panel also provides the History of the conversation between the User and the Copilot chatbot, so that Agent gets the full understanding on the Chat History.
  • Live Agent can directly start interacting with the user.
  • We can view the Power pages porta, the messages from Live agent starts Appearing.
  • Customer also starts interacting back with some follow up questions.
  • Agents can provide the answers. We can also try attaching any supporting documents for the customer if required.
  • Customer can view and download the documents from the Copilot bot inside the Power pages portal.
  • Once the customer is done with the conversation, he closes the chat Window.
  • Once the Customer ends the conversation, the Live Agent using the Customer Service App also gets notified.

Reference Links:

https://learn.microsoft.com/en-us/microsoft-copilot-studio/advanced-hand-off

https://learn.microsoft.com/en-us/microsoft-copilot-studio/configuration-hand-off-omnichannel?tabs=webApp

Happy Copiloting !!!!

Leave a Comment

Your email address will not be published. Required fields are marked *