Dynamics 365 Customer Service with Power Virtual Agents (1)
Published: 2022-12-31 12:48:44

---
title: Dynamics 365 Customer Service with Power Virtual Agents (1)
series: 101 - Dynamics 365 automation with bots/voice bots
published: true
date: 2022-12-31 12:30:43 UTC
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1brhd8p1fqkkamh10mh.jpg
canonical_url: https://the.cognitiveservices.ninja/dynamics-365-customer-service-with-power-virtual-agents-part-1-automation-with-text-chat
---
Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/s/visual/30bb379d-9281-427e-88fc-12110711d779?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
  
---

## automation with text chat
> This article is the first part of a Kickstarter of two pieces and part of my ["Dynamics 365 automation with bots/voice bots 101"](https://the.cognitiveservices.ninja/series/101-d365) series; in this article and in the second part, I will focus on Power Virtual Agent in combination with Dynamics 365 Customer Service. The first article focuses on a text chat virtual agent with a handover option to a human agent, aka live chat. The second will demonstrate how to voice enable D365 and use voice bots.  
> Both pieces will demonstrate that it is possible to provide Omnichannel Customer service with human and non-human agents without a classical Contact Center installation.

## Motivation

Imagine a situation where your virtual agent is incapable of solving a query of your customer; that's the point where human-to-human interactions immediately come into play.

## Configuring the Power Virtual Agent

### Modify Escalate topic

First, we need to modify the default "Escalate" topic to display a meaningful message and handover to the human.
![Figure 1: standard escalate topic](https://cdn.hashnode.com/res/hashnode/image/upload/v1671612288478/NN3u9hC1g.png)
<figcaption>Figure 1: standard escalate topic</figcaption>

Modify the "Message" node with a meaningful message and insert a new "Transfer to Agent" node. By now, we leave the handover to the agent node empty, but this is where you could insert a summary for the human agent.
![Figure 2: modified escalate topic](https://cdn.hashnode.com/res/hashnode/image/upload/v1671619230134/J6GYPwQcb.png)
<figcaption>Figure 2: modified escalate topic</figcaption>
  
### Publish the bot

After creating your Power Virtual Agent and modifying your "escalate" topic, it is time to publish your work to make it visible to the outside world.
![Figure 3: Publish your bot](https://cdn.hashnode.com/res/hashnode/image/upload/v1671612905202/qlihh1S2m.png)
<figcaption>Figure 3: Publish your bot</figcaption>

## OmniChannel Handover

### Configure Power Virtual Agent handover

It would be best if you had a working Dynamics 365 Customer Service environment to work with Omnichannel and human handover. As this is a Kickstarter, I will demonstrate how to start from nothing; you could even start with a 30-day free Dynamics 365 Customer Service trial.

First, we need to activate Agent Transfer with Omnichannel.
![Figure 4: Configure Omnichannel](https://cdn.hashnode.com/res/hashnode/image/upload/v1671612997887/oo2ctf9VP.png)
<figcaption>Figure 4: Configure Omnichannel</figcaption>

![Figure 5: Press enable](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613028346/Kw5pQXjCB.png)
<figcaption>Figure 5: Press enable</figcaption>

We enable voice as we will use it in the second part of this Kickstarter.  
If there is no active subscription for D365 Customer Service, we can enable a trial and select the created environment to use with Omnichannel.

![Figure 6: Start a trial if needed](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613112145/gtsniJXan.png)
<figcaption>Figure 6: Start a trial if needed</figcaption>
  
![Figure 7: Enter your email address](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613198214/FNRO11b1i.png)
<figcaption>Figure 7: Enter your email address</figcaption>

![Figure 8: Launch trial](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613252573/MqHHRbelb.png)
<figcaption>Figure 8: Launch trial</figcaption>

![Figure 9: Remember your D365 URL](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613307256/HvTOhbKt-.png)
<figcaption>Figure 9: Remember your D365 URL</figcaption>

![Figure 10: Select your new environment](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613425840/3fm5nPrRH.png)
<figcaption>Figure 10: Select your new environment</figcaption>

### Create Application Registration

After configuring these initial steps, we need to create an Application Registration in our Azure Active Directory. We go to the [Azure Portal](https://aad.portal.azure.com) and select Application registrations and "+Add".

![Figure 11: Select App registrations](https://cdn.hashnode.com/res/hashnode/image/upload/v1672307858841/f4604026-1ab5-4efb-a37f-4a7219baadf1.png)
<figcaption>Figure 11: Select App registrations</figcaption>

We give it a speaking name and select "Accounts in any organizational directory".

![Figure 12: Configure App registration](https://cdn.hashnode.com/res/hashnode/image/upload/v1671613664882/C2ElTgc_d.png)
<figcaption>Figure 12: Configure App registration</figcaption>

After saving, we can get the Application ID of the Registration (red)

![Figure 13: Remember your Application ID](https://cdn.hashnode.com/res/hashnode/image/upload/v1671614052287/mg7SrPCoP.png)
<figcaption>Figure 13: Remember your Application ID</figcaption>

and paste this ID to our Agent Handover Configuration in Power Virtual Agent.

![Figure 14: paste in your Application ID](https://cdn.hashnode.com/res/hashnode/image/upload/v1671614098326/zvEXALhyt.png)
<figcaption>Figure 14: paste in your Application ID</figcaption>

![Figure 15: find your bot connected](https://cdn.hashnode.com/res/hashnode/image/upload/v1671614254410/-8RMWaRoS.png)
<figcaption>Figure 15: find your bot connected</figcaption>

### Setting up OmniChannel for Customer Service

We need to add some extensions to our environment, to add some features, but everything you see below will work without any extension installed.

#### **For only text (messaging) hand-off**

Install [Omnichannel Power Virtual Agent extension](https://appsource.microsoft.com/product/dynamics-365/mscrm.omnichannelpvaextension).

![Figure 16: install extensions](https://cdn.hashnode.com/res/hashnode/image/upload/v1671614810833/vETHbFeWa.png)
<figcaption>Figure 16: Install extensions</figcaption>

If you still see the following warning after installing the Omnichannel Power Virtual Agent extension and don't need voice capabilities, you can safely ignore it.

![Figure 17: ignore warning](https://cdn.hashnode.com/res/hashnode/image/upload/v1671615021614/VxtMoLK08.png)
<figcaption>Figure 17: ignore the warning</figcaption>

#### **For both text and voice hand-off**

Install the following extensions in this order:

1. [Power Virtual Agents telephony extension](https://appsource.microsoft.com/product/dynamics-crm/mscrm.mspva_telephony_extension)

2. [Omnichannel Power Virtual Agent extension](https://appsource.microsoft.com/product/dynamics-365/mscrm.omnichannelpvaextension)

3. [Omnichannel Voice Power Virtual Agent extension](https://appsource.microsoft.com/product/dynamics-365/mscrm.omnichannelvoicepvaextension)

### Configure Omnichannel for Customer Service

Next, we will create a Queue, a Workstream, and Ruleset.

First, go to https://yourtenant.crm.dynamics.com/apps

![Figure 18: Go to your D365 Dashboard](https://cdn.hashnode.com/res/hashnode/image/upload/v1671615429573/g2CsyXXRi.png)
<figcaption>Figure 18: Go to your D365 Dashboard</figcaption>

Select the "Customer Service admin center App"

![Figure 19: Check bots' existence](https://cdn.hashnode.com/res/hashnode/image/upload/v1671615609244/89t3l0C2J.png)
<figcaption>Figure 19: Check bots' existence</figcaption>

### Create a Queue

We create a separate Queue for Customers asking for human-to-human interaction.

We select the Type "Messaging" as a queue type

![Figure 20: Create a queue](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617209789/5gH12BAYC.png)
<figcaption>Figure 20: Create a queue</figcaption>

![Figure 21: see "users missing" message](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617444030/UaDGECNLi.png)
<figcaption>Figure 21: see the "users missing" message</figcaption>
  
and add some agents after completing it.

![Figure 22: add at least one user](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617493055/BjOp_s-mg.png)
<figcaption>Figure 22: add at least one user</figcaption>

### Create a Workstream

After creating the first queue, we generate a workstream to select the Work distribution mode and the fallback queue.

![Figure 23: Create and configure a workstream](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617798982/XaBAYTE1T.png)
<figcaption>Figure 23: Create and configure a workstream</figcaption>

Next, we create a chat widget; you could use a different, more customizable chat window configuration. You can find an example in my ["Create your first (voice-) bot"](https://the.cognitiveservices.ninja/build-your-first-voice-bot-with-microsoft-power-virtual-agent-3e71f8531c3a) article.

Click "Set up chat" and configure it accordingly to the screenshots.

![Figure 24: see "live chat required" message](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617866399/PGiD3CSup.png)
<figcaption>Figure 24: see "live chat required" message</figcaption>

![Figure 25: configure live chat - part 1](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617915324/uoZMgig5l.png)
<figcaption>Figure 25: configure live chat - part 1</figcaption>

![Figure 26: configure live chat - part 2](https://cdn.hashnode.com/res/hashnode/image/upload/v1671617960778/CngUxJkU7.png)
<figcaption>Figure 26: configure live chat - part 2</figcaption>

![Figure 27: configured live chat](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618031262/kNw3aWFl1.png)
<figcaption>Figure 27: configured live chat</figcaption>

### Add a RuleSet

Next, we create a ruleset for handling the users.

![Figure 28: create a ruleset](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618129956/AE_wje1Uo.png)
<figcaption>Figure 28: Create a ruleset</figcaption>

and create a new rule.

We do not need to configure a condition, as we want to allow every user to enter the queue and assume you have a 24/7 service.

![Figure 29: create a rule](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618651270/0uRUEq6Dz.png)
<figcaption>Figure 29: Create a rule</figcaption>

### Add Bot to Workstream

We add our bot via smart assist bots' settings in the Advanced settings area.

![Figure 30: Add bot to workstream](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618778906/KR9fW0qveL.png)
<figcaption>Figure 30: Add the bot to the workstream</figcaption>

### Add Context Variables

We need to add a first context variable to the workstream.  
We will use the va\_Scope Variable.

![Figure 31: test the chat, to display the context variables](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618906798/38OGXqf_c.png)
<figcaption>Figure 31: test the chat to display the context variables</figcaption>

![Figure 32: see the context variables](https://cdn.hashnode.com/res/hashnode/image/upload/v1671618928115/8a4WRtdl6.png)
<figcaption>Figure 32: see the context variables</figcaption>

![Figure 33: add context variables](https://cdn.hashnode.com/res/hashnode/image/upload/v1671619006480/3wGxHfnHY.png)
<figcaption>Figure 33: add context variables</figcaption>

![Figure 34: Create context variable](https://cdn.hashnode.com/res/hashnode/image/upload/v1671619066653/CvyxqzfgF.png)
<figcaption>Figure 34: Create context variable</figcaption>

## Test handover

Let's test the handover.

Go to your workstream, copy the code for the snippet, create an empty HTML-File and paste the copied code into the body.

![Figure 35: Copy code snippet](https://cdn.hashnode.com/res/hashnode/image/upload/v1672309451546/60fdf04b-15f7-444e-8ac1-5e4d5b5882b4.png)
<figcaption>Figure 35: Copy code snippet</figcaption>

You will end up with something looking like this.

```
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script id="Microsoft_Omnichannel_LCWidget" src="https://oc-cdn-public-eur.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js" data-app-id="your data" data-lcw-version="prod" data-org-id="your data" data-org-url="https://your data.crm4.omnichannelengagementhub.com"></script>

</body>
</html>

```

Open the HTML File with your Browser and start chatting.
![Figure 36: start the dialog](https://cdn.hashnode.com/res/hashnode/image/upload/v1672309876905/a7e6c3f7-b9fe-40f6-98c7-9adbdf809679.png)
<figcaption>Figure 36: start the dialog</figcaption>

Ask the bot for a human agent.

![Figure 37: ask for agent](https://cdn.hashnode.com/res/hashnode/image/upload/v1671620084277/PcM67bgTi.png)
<figcaption>Figure 37: ask for an agent</figcaption>

In your D365 Agent Dashboard, you should see an incoming chat and can talk to yourself.

![Figure 38: answer request](https://cdn.hashnode.com/res/hashnode/image/upload/v1671620151552/T-u8MZUbZ.png)
<figcaption>Figure 38: answer request</figcaption>

The agent can see the customer's dialog with the bot on the left side.
![Figure 39: Explore interface](https://cdn.hashnode.com/res/hashnode/image/upload/v1671620229284/uSJH465Yl.png)
<figcaption>Figure 39: Explore the interface</figcaption>

And can start to chat with the customer.

![Figure 40: customers' view](https://cdn.hashnode.com/res/hashnode/image/upload/v1671620290256/gYJns5X3p.png)
<figcaption>Figure 40: customers' view</figcaption>

## Conclusion

Self-service helps you provide 24/7 effective and efficient customer service; with the integration of human handover, you can keep your customer satisfaction high.