Provide Sentiment Analysis through Chatbot by using Power Virtual Agents
Power Virtual Agents (VA) is one of the Microsoft Power Platforms that provide the ability to build chatbots in a code-less graphical environment without the need for data scientists or developers. In another word, it enables everyone to be a chatbot developer.
On this occasion, I would demonstrate how to build a chatbot to provide a sentiment analysis prediction. There are two Power Platform services we are going to use here: Power Virtual Agent and Power Automate.
Let’s go dive in!
Create the Chatbot
First, let’s go to the Power VA homepage here. Take a look at the top-right of the website, choose the bot icon.
On the bot dashboard, go to the Topics menu. Next, choose New topic to create a new topic. We are going to use this topic to provide the sentiment analysis service.
Name the topic with “Analyze Sentiment” or anything else that represents the topic. Then, add several phrases on the Trigger phrases. When you have set all the phrases, you could close the pane.
Now, on the canvas, if you have another node after the Trigger node, you could delete it first. Then, add a Question node after the Trigger node.
Set Identify on the Question node to User’s entire response. To make it easier on the next development process, specify a variable name on the Save response as part.
The canvas now would look like the below image.
Under the Question node, add an Action node by choosing Call an action. On the pop-up, choose Create a Flow.
You would be redirected to the Power Automate website to create a flow. We are going to use this flow to provide the sentiment prediction by using AI Builder.
The initial workflow would look like this one.
On the Power Virtual Agents step, click Add an input. Choose the type of user input as Text. Next, set the title and fill in the description.
Between the Power Virtual Agent step and Return value(s)… step, insert another step by choosing Add an action. Search for “sentiment” in the search box, then choose the one provided by AI Builder.
You could choose your preferred language as the language the AI would use as the based language to predict sentiment. Here, I select English as the language. For the Text field, choose to_analyze.
Next, add a Text output on the Return value(s)… step. Enter Result as the title and select Overall text sentiment as the response’s value.
As the last step on the Power Automate, rename your flow as your preference and then save the flow.
Back to the Power VA canvas, on the Action node, choose the flow we just created. Set the rest as the below image.
After that, let’s return the sentiment prediction result to users. Add a Message node and write a message to be provided to the user. The prediction value is accessible through a variable called Result. You could add the variable by choosing the variable icon.
We are all set! You could modify and add other nodes to the topic to give a better user experience. Now, let’s test our bot!
Test the Bot
We could test our bot by using the Test bot pane on the left. If the pane is not visible, you could click Test your bot on the bottom-left of your screen. Here is my test result.
Publish the Bot
Power VA provides the ability to publish the bot into a live accessible environment.
Now, go to Publish menu through the left pane. Then, hit the Publish button and wait for the bot to be published. We could view our bot through a demo website through the demo website hyperlink.
We could also deploy the bot through several channels such as Facebook Messenger, Microsoft Teams, Telegram, and many others.
The Demo website channels could also be customized. We could then share our bot by sharing the link provided in the Share your website area.
Here is what my demo website looks like. It is accessible here.
Analyze the Bot Performance
As our users grow, we could then analyze the bot performance. Go to the Analytics menu on the left pane. Here is my bot performance after several uses on the demo website.
This sentiment analysis chatbot is just one of the implementation of Power Virtual Agents. Interesting, isn’t it?
And, there are many more possibilities when we build a chatbot in Power Virtual Agents. Here are several references you could use to explore Power VA.