Create a Power Virtual Agent to do Sentiment Analysis with the Power Platform

February 6, 2023
13 min read

Introduction

Sentiment analysis is the process of using natural language processing, text analysis and computational linguistics to identify and extract subjective information from source materials. It is used to determine the attitude, opinions and emotions of a speaker or writer with respect to some topic or the overall contextual polarity of a document.

One example of how sentiment analysis can be used in human resources is to analyze employee feedback. An HR department could use sentiment analysis to automatically process and categorize employee surveys, to quickly identify patterns of positive or negative sentiment among employees about specific topics such as work environment, management, or benefits. This could help the HR department identify areas where the company is excelling and areas where improvements can be made.

This is just one of the reasons why sentiment analysis has become an essential tool for businesses looking to understand customer or employee feedback and make data-driven decisions. Power Platform, a low-code platform that enables users to build workflows and automate processes, offers a simple and effective way to perform sentiment analysis on large volumes of text data.

With Power Platform, businesses can easily create and customize sentiment analysis workflows to suit their specific needs. Whether it's analyzing customer reviews, social media posts or survey responses, sentiment analysis can help identify patterns and trends in customer feedback, understand customer needs and concerns, and ultimately improve products and services.

We will take a closer look at the benefits of using Power Platform for sentiment analysis and provide a real-world example of how it can be used to drive business growth. This article is designed for business owners, marketers and data analysts who want to gain a deeper understanding of how sentiment analysis can help them make better decisions and improve their bottom line.

We will explore the use of sentiment analysis using AI Builder to gather employee feedback and respond appropriately. AI Builder is a service provided by Microsoft that allows users to build and deploy custom machine learning models without having to write any code. It includes pre-built models for common business tasks such as sentiment analysis, object detection and form processing. One of the pre-built models provided by AI Builder is a sentiment analysis model. This model can be used to automatically classify text as positive, negative, or neutral sentiment. It can be used to analyze customer feedback, social media posts and other forms of written text to gain insight into how people feel about a particular product, brand or topic. AI Builder provides an easy-to-use interface for building and deploying custom models, including sentiment analysis models. It also allows users to fine-tune the pre-built models to better match the specific data and use case. Once the model is trained, it can be integrated with various Microsoft products such as Power Automate, Power Apps and Dynamics 365, to automate business processes and improve decision making based on the insights generated from the sentiment analysis.

We will cover three possible scenarios — positive, negative, and neutral — and how to handle them using Power Automate, Power Virtual Agents and Microsoft Teams. By the end of this article, you will have a clear understanding of how to use these tools to analyze employee feedback and improve your HR processes. We will also provide the links for the specific tools required for this process: Power Automate, Power Virtual Agents and Microsoft Teams.

First step: set up a Power Virtual Agent

The first step in implementing this solution is to set up a Power Virtual Agent. Power Virtual Agents is a service provided by Microsoft that allows users to create and deploy chatbots without having to write any code. It is a part of Power Platform and can be used to automate customer service, helpdesk and other common business tasks. In the following case, the bot will serve as the primary means of communication between the employee and the sentiment analysis system. As we progress through the process, you'll see that we will integrate this Power Virtual Agent into an existing scenario that employees are already familiar with. The third step (below) will cover this in more detail.

1. To start, log into Power Virtual Agents, fill out the required information and select Create.

A dialog box shows 3 required fields, name the bot, pick a language, select an environment from a list, required to create a chatbot in Microsoft Power Virtual Agents.
Figure 1: Log into Power Virtual Agents and fill in the required fields to create your first chatbot.

 

2. Next, navigate to the Topics section and select +New topic. Give the topic a name of your choice. In this example, we have already created a topic called "Employee feedback," which will become clear later in the article.

At the top of the Power Virtual Agents form, click + New topic and name the topic Employee feedback.
Figure 2: Create a topic named “Employee feedback” in Power Virtual Agents.

3. Identify the trigger phrases that you would like your bot to respond to. Once you have a list, add them to the Trigger Phrases box.

A dialog box shows a list of seven trigger phrases your bot will respond to.
Figure 3: Add a list of trigger phrases for your chatbot to act on.

4. When creating your bot's message, include a question as well. Keep in mind that you may need to adjust some default values and options, as demonstrated in the accompanying video.

The following changes were made after the initial configuration, as you can appreciate in figure 4.

  • The Identify option was set to User's entire response.
  • The Save response as option was set to VarUserResponse.
Power Virtual Agents studio shows three boxes, one to indicate trigger phrases, a welcoming message and a question for the user to answer.
Figure 4: Create a chatbot, adding trigger phrases, a welcoming message and a question.

5. Next, add an action and select Create a flow.

After a Power Virtual Agent question, create an action, which launches Power Automate in a new window.
Figure 5: As a response to a bot question where the answer is stored, create a Power Automate flow as an action.

At this stage, a new tab for Power Automate will open from the Create a flow in figure 5. Now Power Automate has launched as shown in figure 6.

Power Automate has launched and you can add either click to add an action to handle user input or click to add an action to return a value to the Power Virtual Agent.
Figure 6: Creating a new flow launches Power Automate where you can add an input or return a value to the chatbot.

Second step: Power Automate

The second step in this process is to set up Power Automate. This tool will analyze the sentiment of the phrase the employee inputs into the system and provide them with different answers based on the outcome. Additionally, it will trigger certain actions with the HR team.

1. To begin, fill in the first box as demonstrated:

A dialog box prompts you add an input to have analyzed.
Figure 7: Add an input.

2. Add an action and select Analyze positive or negative sentiment in text. Fill in the required fields as follows:

A dialog box prompts you to choose a language from a list and then add an action to have the text the user typed analyzed for positive or negative sentiment.
Figure 8: Add an action to have the text the user typed analyzed for positive or negative sentiment.

3. Add another action and select Initialize variable. Fill in the fields as shown:

A dialog box prompts you to create a string variable named VerFeedbackSentiment initialized with the Overall text sentiment.
Figure 9: Initialize a string variable named VerFeedbackSentiment and assign it the value from the Overall text sentiment.

4. Add an action and choose Initialize variable. Complete the fields as follows:

A dialog box prompts you to add a variable named VatBotResponse, of type string.
Figure 10: Initialize a string variable named VatBotResponse.

5. Add an action and select Switch. Complete the On variable field as follows:

null
Figure 11: Add an On variable named VerFeedbackSentiment (which you created in figure 9)

Now you will need to decide how your bot will respond to positive, negative and neutral inputs. You can refer to this example for inspiration.

  • In the Case: positive section, select Set variable and fill in the name and text you would like customers to receive in positive cases.
In the dialog box, you can set values for the case where the input response equals positive, assign the text in the Value field to the VatBotResponse variable.
Figure 12: In the case of a positive input response, assign the text in the Value field to the VatBotResponse variable.
  • The Case: negative section differs from the positive case. We want to escalate the received feedback to the HR team via email. The first step is the same as the positive case, but an additional step is added: "Send an email (V2)." Fill in the To, Subject and Body fields. In the body, include a dynamic field so that the recipients are aware of the submitted response and can take appropriate action.
In the dialog box, you can set values for the case where the input response equals negative, plus create an email alert, which appears in another dialog box, where you set a designated person or group with custom details and some boilerplate text including the negative response received.
Figure 13: In the case of a negative input response, assign the text in the Value field to the VatBotResponse variable plus create an email alert to a designated person or group with custom details and some boilerplate text including the negative response received.
  • The neutral case is easy to understand, similar to the positive case. Complete as follows.
In the dialog box where there is no positive or negative input response, you assign simple text like “Thanks!” to the VatBotResponse variable
Figure 14: In the case of a neutral input response, assign the text in the Value field to the VatBotResponse variable.

6. To save feedback and sentiment, select the Create option under SharePoint actions. The following information is required: Site Address, List Name and Title.

Action Create item Save Feedback and Sentiment, select a site address, list name and title.
Figure 15: Power Automate box showing the action Create item Save Feedback and Sentiment.

7. We will send these values back to HR Bot — Power Virtual Agents (created in figure 1).

A dialog box where you send the value saved in the VatBotReponse variable (positive, neutral or negative) back to the HT Bot to show the user for provided the input response.
Figure 16: Based on the positive, neutral or negative input response, send the Value text assigned to VatBotResponse back to the HR Bot chatbot, who will display the text to the user.

The flow you have created should resemble the following:

This figure shows the whole Power Automate flow from beginning to end that you created in the steps above to collect input response, trigger an evaluation, and assign response text for the chatbot to display.
Figure 17: The whole flow created in Power Automate that collects input response, triggers an evaluation of the text, assigns response text and send the response back to the chatbot.

Returning to the first step: Power Virtual Agents.

After creating the flow, you will see that a new box is filled in with new information:

This dialog box shows that the action you created in figure 5 now includes the flow you just created in Power Automate.
Figure 18: The Power Virtual Agent you are creating has the flow you just created in Power Automate.

You will need to create a new message and include the variable Response.

Message box including the response variable.
Figure 19: Create a new message that includes the variable named Response.

Third step: Publish the Power Virtual Agent on Microsoft Teams.

Utilizing Microsoft Teams is a wise choice as it will be easily adopted by employees, as they are already familiar with Teams for various tasks.

1. In Power Virtual Agents, navigate to Publish and choose Go to Channels.

The Publish form lets you start the process of publishing HR Bot to a channel.
Figure 20: Publish the HR Bot to a channel. You have about a dozen choices.

2. Select Microsoft Teams.

As part of publishing your Power Vitual Agent, choose Microsoft Teams as the channel where you want it to be used.
Figure 21: Choose to publish HR Bot to Microsoft Teams.

3. A new tab will open. Select Turn on Teams.

Power Virtual Agents studio showing the ability to Turn on Teams to publish HR Bot just created.
Figure 22: After selecting Microsoft Teams (figure 21) a form opens where you can Turn on Teams to start publishing HR Bot.

4. This tab will open, select Edit details.

Power Virtual Studio showing how to edit details before publishing the HR Bot within Microsoft Teams.
Figure 23: As part of turning on teams, choose to edit details.

5. You can modify the details if desired, once you have finished, select Save.

Image showing Power Virtual Agents studio, editing the color of the bot, short and long descriptions.
Figure 24: On the Edit details pane, at a minimum, you’ll be required to enter a short description and a long description (if they are empty) before you can Save.

6. Select Publish.

Image showing Power Virtual Agent studio, ready to publish the bot.
Figure 25: Now that the channel details are confirmed, you can click Publish.

7. Confirm.

A dialog box asking you to confirm that you want to publish.
Figure 26. And of course, confirm that you do want to publish.

Add bot to Microsoft Teams

1. Search for the bot.

Image showing the HR Bot created and ready to be installed.
Figure 27: Now in the Apps section in teams, you can search for the Employee FAQ, which will start the Power Virtual Agent you published.

2. Test the solution. 
a. Positive

Video 1: Demonstrates positive sentiment interaction with the Employee FAQ chatbot that was published to Teams.

b. Negative

Video 2: Demonstrates negative sentiment interaction with the Employee FAQ chatbot that was published to Teams.

This screenshot shows the email generated from the flow for a detected negative sentiment interaction which includes the response text from the user.
Figure 28: The text of the email with boilerplate text that includes the response text from the user, which is sent to the configured email from the flow.

3. Neutral

Video 3: Demonstrates neutral sentiment interaction with the Employee FAQ chatbot that was published to Teams.

Conclusion

In conclusion, sentiment analysis using the Power Platform can be a powerful tool for businesses looking to gain valuable insights into customer opinions and feedback. By using natural language processing and machine learning techniques, the Power Platform can analyze large amounts of customer data and provide valuable insights into overall sentiment, as well as specific topics and keywords. This can help businesses identify areas of improvement and make more informed decisions. Overall, the use of sentiment analysis on the Power Platform can lead to more effective customer engagement and better business outcomes.

Ana Inés Urrutia de Souza

Ana Inés Urrutia de Souza

Ana Inés Urrutia de Souza (https://www.anainesurrutia.com/) is a Microsoft Most Valuable Professional (MVP) with a reputation as a worldwide reference in Dynamics 365 Human Resources, Employee Experience, and Power Platform. She is a recognized leader in the field of human resources and has a wealth of experience and knowledge to share.

With her deep understanding of Microsoft technologies, Ana has become an expert in the implementation and use of Dynamics 365 and Power Platform for Human Resources. She is a sought-after speaker at conferences and events and frequently provides training and guidance to other professionals in the field.

In addition to her technical expertise, Ana is also a mentor and community leader. She is passionate about sharing her knowledge and experience to help others succeed and is committed to fostering a supportive and inclusive community in the HR and technology sectors.

With her combination of technical acumen and leadership skills, Ana has established herself as a true authority in the field of Human Resources and Dynamics 365 and continues to push the boundaries of what is possible within this field.