In this #PowerShot, I will show you how to get started with the Power Virtual Agents on the PowerPlatform and integrate MS Power Automate (MS Flow) with it to complete a LowCode NoCode bot service that can be integrated across platforms.
Let's Get Started!
We will create a customer requests management service chat bot and deploy it on an ASP.NET site. This chat bot is powered by the Power Virtual Agent and MS Power Automate.
There are two process that we will look into here: (as an extension of one of my previous articles: MS Flow as a Service)
Process 1: The customer interacts with the chat bot to create a new request.
Process 2: The customer interacts with the chat bot to get the status update on a previously created request.
MS Power Virtual Agent
Step 1: Log on to https://powervirtualagents.microsoft.com/ and select Explore Bots -> Create a New Bot and provide a name for the bot. You can change the environment in which this bot is created by selecting the desired environment in the advanced settings.
Step 2: Once the bot is created (it may take up to 15-30 minutes for the bot to get provisioned), Click on customize your greeting and this will take you to the editor canvas.
Step 3: You will see a set of actions already added and now you can start editing the flow of the bot as per the requirement. For the scenario that we are building, add a new node and select "Bot Says" and enter the following:
Enter 1 to create a new request
Enter 2 to get status of a previous request
Enter 3 to end chat
Enter 4 to connect with an agent
These response keys will then shape the responses and the further behavior of this bot. Below this, add another node as "User Says" and add the 4 options that allow the user to select that from the bot response itself.
Step 4: You will now see 4 condition steps for the 4 types of responses and each branch needs to be separately configured.
For Condition Branch 1: To create a new request:
Step a: Add a node as "Bot Says" and enter "Enter Your Name" to request the name of the user.
Step b: Add a node as "User Says" and initialize a variable to record the name input provided by the user.
Step c: Similarly replicate for two more inputs to record the Email Address and Comments from the user.
Step d: Add a node as "Action" and select the 1st flow to create a new request. Select and provide the appropriate variables for each of the inputs to send to the flow.
Step e: Add a node as "Bot Says" and select the output variable from the flow to send the response from the flow to the user.
Step f: Add a node as "End Chat with Feedback" to end this branch.
For Condition Branch 2: To get status of existing request:
Step a: Add a node as "Bot Says" and enter "Enter request tracking number" to get the request number from the user.
Step b: Add a node as "User Says" and initialize a variable to record the request id input provided by the user.
Step c: Add a node as "Bot Says" and enter "Checking" so that the user is on hold while the flow runs and gets the response.
Step d: Add a node as "Action" and select the 2nd flow to get request status. Select and provide the appropriate variable for the input to send to the flow.
Step e: Add a node as "Bot Says" and select the output variable from the flow to send the response from the flow to the user.
Step f: Add a node as "End Chat with Feedback" to end this branch.
For Condition Branch 3: To end chat:
Step a: Add a node as "End Chat with Feedback" to end this branch.
For Condition Branch 2: To connect to an agent:
Step a: Add a node as "Transfer to Agent" to end this branch. (Here you can add more custom set of responses or provide any live support as applicable.)
Now let's look at the Flows created in MS Power Automate to integrate with the MS Power Virtual Agent
Note: These Flows have to be created in a solution in the same environment (default in my example) as the Virtual Agent.
Both the flows will be created with the "When an HTTP request is received trigger" and correspond to the schema/ process as defined here.
Flow 1 (Create a new request)
The JSON schema in the trigger has 3 keys: name, email and comments that will be received from the user and used to create the item in SharePoint.
The "Response" action at the end has a key "ResponseVal" that will be sent as an output to the virtual agent.
Flow 2 (Get request status)
The JSON schema has the key "trackingNumber" that will be requested from the user and then further this will be used to retrieve the item from the SharePoint list.
The "Response" action at the end has a key "ResponseVa" that will be sent as an output to the virtual agent.
Deployment
Once the above setup is complete, you can move to deployment tab and check the functioning of the virtual agent on a test site.
Once completed testing on the test site, this virtual agent can be deployed to a custom site using an iframe on an HTML page. (You can provide any customization/ styling as required)
<body>
<iframe src="https://va.ai.dynamics.com/webchat/bots/yourbotidhere" width="560"; height="400"></iframe>
</body>
Setup in Action
In this post, we saw how to get started with the MS Power Virtual Agent and invoke flows from MS Power Automate to create a LowCode NoCode chat bot service for automating customer request management.
Once created, the virtual agent can be deployed on webapps across different platforms by using a simple iframe HTML.
The overall performance and metrics of this virtual agent can be monitored on the MS Power Virtual Agents portal.
I highly recommend to check out this video for ease of understanding on integrating MS Power Virtual Agents with MS Power Automate.
I hope you found this interesting and it helped you!
Comments