Introduction
In this article, you will see how to create a bot using Power Virtual Agents and how to call an action using Power Automate. I have created a SharePoint list named “Request Lists” which contains the following information.
User can check the request status by entering the request ID using the bot. Bot calls the Power Automate in the background to retrieve the information from SharePoint list using SharePoint connector.
Power Virtual Agents
Power Virtual Agents allow us to easily create powerful bots using guided, no-code graphical interface without the need for data scientists or developers (coding or AI expertise). You can do the following using Power Virtual Agents,
- Empower your teams
- Reduce costs
- Improve customer satisfaction
To learn more about Power Virtual Agents and to get started refer to this
link.
Flow Design
Topic Design
Create a bot
- Navigate to here.
- Create a new bot as shown below.
- Enter the name for the bot and click Create.
Create a new topic
A topic defines how a bot conversation plays out. It consists of trigger phrases and conversation nodes.
Trigger phrases - phrases, keywords, or questions that a user is likely to type that is related to a specific issue.
Conversation nodes - to define how a bot should respond and what it should do.
- In the newly created bot (refer above section), click Topics in the left navigation.
- Click New topic.
- Enter the name, description and trigger phrases as shown below. Click Go to authoring canvas.
- Delete the message as shown below.
- Click + Icon and then click Ask a question.
- Enter the question, select User’s entire response for Identity and rename the variable as var_requestID.
- Click + icon and then click Call an action. Click Create a flow.
- In the Power Automate portal, update the JSON schema in “When a HTTP Request is received” as shown below.
- Delete Initialize variable – String and Initialize variable – Number
- Add Get Items SharePoint action and configure the Site Address & List Name.
- Add Filter array action and configure the values by adding dynamic vales from previous actions as shown below.
- Add three Initialize variable actions and configure it.
- Initialize variable – Request Title action: value - json(string(first(body('Filter_array'))))?['Title']
- Initialize variable – Comments action: value - json(string(first(body('Filter_array'))))?['Comments']
- Initialize variable – Status action: value - json(string(first(body('Filter_array'))))?['Status']?['Value']
- Update the Body and Response Body JSON in Respond to Power Virtual Agents action as shown below.
- Update the flow name as Request Status and save the flow.
Create a new solution in Power Automate
- In the Power Automate portal, click Solutions. Click New solution.
- Enter the details for the new solution and then click Create.
- Go to newly created solution, click Add existing. Click Flow.
- Click Outside solutions, select the newly created flow Request Status and then click Add.
- Flow added to solution successfully.
- Navigate to Power Virtual Agents, go to Get Request Status topic which was created in the previous section. Click + icon and click Call an action. Newly created flow will be available click that flow.
- Select the variable from the drop down as shown below.
- Click + icon and click Show a message. Add the text and output variable values as shown below.
- Save the topic.
Test the bot
- In the left navigation, click Test your bot. Enter request status and wait for the bot response.
Summary
Thus, in this article, you saw how to add action to a bot (created using Power Virtual Agents) using Power Automate.