Hello Bot developers !

Microsoft has recently released its new powerful chat bot platform aka Power Virtual Agents and it is generally available now. It is one of the most awaited things from Microsoft. This product is featured as a competitor of Dialog flow (Google) and IBM Watson. The Power Virtual Agents gives flexibility to create your own business flow run time. Which was not possible in the Microsoft Bot Framework. If you guys ever built a bot, you know what are the complex process involved in changing the bot conversational flow. So here we go, lets learn on How to create a bot with Power Virtual Agents.

First Things First

To start using Power Virtual Agents , I would suggest you should have some basic idea on Power Virtual Agents and Bots. You can visit my blog post to have some information.

Step 1: Create your first Power Virtual Agent

First, you need to go https://make.powerapps.com/

Here, you will find the chat bots section on the left hand side of the page as shown below.

Here, you can select Create link from left side or click on + New Chatbot in the header.

After clicking on new chatbot link, a new page will open. Here we need to enter the name of chat bot, the language and select appropriate environment. And after entering the details, click on create.

pva-bot-2
Create PVA

This will create your first Power Virtual Agent chatbot. But hang on, we have just started.

Step 2: Overview of PVA

After creating the chatbot, the screen will look like below. Here you can see a test chat panel, customize greeting panel, hide bot panel and left navigation pane.

From the test chat panel, we can test the chatbot flow at runtime. (we will see that later). From the hide bot panel, we can hide the test chat panel. From the left section we can navigate to different parts of PVA. And from customize the greeting section, we can customize the initial greeting dialog.

Each dialog in PVA is called as a Topic. There are predefined topics and custom topics in PVA.

We can click on customize the greeting link, this will redirect us to the customization page of the topic.

Step 3: Create a Topic

A topic can be considered as a dialog/module. We can create a topic for each of the use case that we want to implement. Lets take an example of leave application.

First, we need to go to the Topics section in the left navigation. This will show the list of topics that are available by default. We can explore them by clicking on them. To create one we need to click on the +New Topic in the top header. This will open the dialog like below.

Here, we have to give the name of the Topic as Leave. Then we need to add the description for the topic. After this, we need to write the triggering phrases for the topic. A triggering phrase is the one which will be used to start any topic. We need to be wise and provide as many as possible triggering phrases to start the topic. So for now, we can add the phrases as shown in the image above. After this we can click the save button. This will save the topic. Once the topic is created then we need to create the flow/business logic for the topic.

Step 4: Create the flow with authoring canvas

To create the flow, we need to click on the Go to Authoring canvas button in the topic. This will open up the authoring canvas of the bot. The authoring canvas looks like below.

Here we can add multiple type nodes by clicking on the plus icon. Lets start with the basic one and try a simple message to the bot. To do this, click on the add icon and select the show a message link. This will open a text area where we can write our own message. Lets write welcome message as shown in the image.

This will show a message in the chat window to the user. We can also make it Bold, Italic and also can give numbers.

Now, lets create a decision tree flow. So to do this again click on the add icon after the message and select Ask a question link. This will open a Ask a question node and here we can set different type of inputs. We can try with the multiple choice options. We can also set the question that the bot need to ask. After selecting the multiple choice question, we need to give the choices of selection. The choices will be rendered as a button in the chat window. We can add two choices here for the user’s selection. Casual leave and Sick leave.

After this, we need to store the user’s response in a variable. So we can create a new variable here and set the name as LeaveType and keep the variable scope as a bot level. So any node in the bot can use the variable.

as we keep adding the choices , the decision tree will be created below the current node. You now set the different flow for each selection.

Lets ask the user to enter the date for their leave. To do this, click on the add icon below the sick leave action and add ask a question. Here, in ask a question we need to type our question. Lets ask “When do you want to take a leave”. Here we need to select the identify to date and time. This will identify the users and the date and time by using NLP services. We can store the output of of the date and time in to a new variable called LeaveDateTime.

After this action let’s add a show message action and display the user’s leave type and leave dates. We can write ” you applied for <variablename> for <variablename>

So by doing this, our basic chatbot flow will complete. lets save the authoring canvas and let’s test our chatbot. We can go to the test the chat what section on the left hand side and test our bot by writing I want to apply a leave I want to apply leave in the message box and the chatbot flow for applying a leave will start.

So by using the power virtual agents, we can create dynamic flows very easily. We can use different type of input types based on our requirement.

Happy Coding !