In this article, I want to share a useful example of how to implement day-off tracking for employees in an organization with the help of Power Virtual Agent. This tool is free in Microsoft Teams, does not require much time for implementation and is easy to use.
Power Virtual Agent can ask users questions and understand the answers using natural language processing, but it cannot directly add or read data from the database. To do this, a Virtual Agent can call Power Automate flow, giving the required information as input. Power Automate flow will perform database-related activities and return the output back to the Power Virtual Agent. So chatbot can show the result back to the user.
There are two ways to create a chatbot in the power Virtual Agent based on the available license.
The Stand-Alone Power Virtual Agent portal requires a license for the creator of the chatbot. This chatbot can be published to various channels like external websites, SharePoint, and social media platforms like Facebook.
Power Virtual Agent for Teams version does not require any license. The chatbot will be created in the Dataverse environment for teams. This type of chatbot can only be published in the Microsoft teams.
Below is the diagram that represents various components and how their interaction will happen
We will start with the creation of a bot. In the Microsoft Teams application, Click on the Apps button as shown in the screenshot below and search for the “Power Virtual Agent” Application. Click on it and add it.
Click on the “Start Now” button to create the ChatBot. Select the team’s name. Later, you can find all your chatbots in the “Chatbots” tab. Give a suitable name for your chatbot.
Go to the “Topics” tab in the left navigation. Here you can see all the topics. You can create a new topic by clicking on the “New Topic” button.
Now we will create a new Dataverse table to store Day off requests of all users. Open Microsoft Teams in the new Tab and search for the Power Apps application as shown in the screenshot below.
Open the application and click on the “Build” tab then click on your team’s name. Click on “See All”.
This is the place where you can find all the components created for the team. Create a new table to store the requests with the required columns. For Example:
Name – Date of Day Off Type – Date
Name – Number of days Type – Number
Name – Requester Type – Email
Name – Reason Type – Text
Open the power virtual agent chatbot and create a new topic with the name “New Day Off Request”. Provide the trigger phrases that users can use to create day-off requests. You may provide as many triggers as possible so that the bot can efficiently understand the user’s intention while interacting.
Click on “Go to Authoring Canvas”. Add questions for the information that is required for new Day Off Requests. You may ideally ask a question for each column that you created in the Dataverse table. Refer to the following images for questions to be configured. Save the Topic.
Information about day off requests provided by the user is stored in the variables in the Power Virtual Agent. One Power Automate flow must be created that will take information about the new request from Power Virtual Agent and create a new row in the database. This flow will send an email to the manager to notify him about the new day off request.
In the authoring canvas, select “Call an action”. It will open a list of all the flows available that can be called from the Power virtual agent. Click on Create a flow to create a new flow. It will open the Power Automate interface inside the teams.
You can select the first template of Flow to start with, and then it can be extended according to our use case. This flow will have a Power Virtual Agent trigger. Click on +Add an input to add required values from Power Virtual Agent like Start date, Number of days, Current User email, and Type of leave.
Next, we can configure the logic to add a new row to the database and send an email to the manager. After completing the flow, provide a suitable name and save the flow. Click on the back button to go back to Power virtual agent topic authoring canvas.
In the topic, click on Call an Action and select your flow name. Select the variable names in the dropdowns. In the UserEmail input, use the bot variable UserId that is provided by default from teams.
In the end, add a message to the user that “Your request is submitted successfully”.
Now let’s create a process to get users’ day-off requests. Create a new Topic in the same chatbot. Provide the trigger phrases and click on Go to authoring canvas.
This topic will call Power Automate flow to get all the requests of the current user. Click on “Call an action” and create a new Flow. In the “List rows” action of Power automate, a filter query is used to get requests of the current user.
All the requests’ details will be stored in the string variable, and it will be returned to the Power Virtual Agent. Complete the flow, and navigate back to Power Virtual agent to configure calling this flow from the topic
After finishing both the topics, test your bot in the Test pan available on the left side of the screen. If everything is good, we can publish the flow. In the left navigation, click on Publish tab. The screen below will open. Click on the “Publish” button.
After publishing the bot, click on the second option “Make the bot available to others”.
Click on “Show to my teammates and Shared users”. Then click on the “Share” button.
All the members of the associated team will be able to search for the bot in the app store of Microsoft teams. Go to Apps, click on “Built by your colleagues” and find your bot and open it.
To easily access the bot, you can pin it in the left navigation.
Hope this will help you to automate more requests in your organization with Power Virtual Agent.