Exploring AI in Power Automate – Sentiment Analysis

Sentiment analysis is a powerful technique that helps businesses understand the emotional undertones of customer feedback. By automatically classifying text as positive, negative, or neutral, companies can gain insights beyond simple written words. In this guide, we’ll explore how to build a sentiment analysis workflow using Power Automate that processes customer reviews submitted via email.

Traditional survey methods (like Microsoft Forms) often constrain customer expression, whereas an open email approach offers more flexibility. By allowing customers to share their experiences in their own words, we can capture more nuanced and authentic feedback. This method not only reduces barriers to providing input but also increases the likelihood of meaningful customer participation.

The setup

Setting up an effective sentiment analysis system requires careful infrastructure planning.
We’ll create three essential components to streamline our customer feedback process: a shared inbox to receive reviews, a SharePoint teamsite for centralized oversight, and a SharePoint list that holds the customer reviews and their analysed scores.

The teamsite

The first step in our sentiment analysis project involves creating a SharePoint team site, which offers integration with Microsoft Teams. Here’s how to set up your collaborative workspace:

Navigate to the site management in the (https://<tenantname>-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/siteManagement/) and create a new teamsite.
You are free to chose the name and the template type, for this guide I am going to use the Microsoft Standard Teamsite template and set the name to Customer Review Team

After our teamsite has been created, open its settings and click on the Add Teams-Button in the banner that says
Would you like to add Microsoft Teams to this group?

The list

To store our review data and scores, we are going to need a list.
Open the previously created teamsite and create a new list (Site contents → New → List).
Use the blank list template and name it Customer Reviews.

The list gets created containing only the Title column. We are going to add the more columns, to hold the From-Address, the Review-Text (Body) and the score.
The following screenshots will show you how to configure the columns

The shared mailbox

The last setup step we have to take is creating a shared mailbox where our customers can send the reviews to.
Open the Microsoft 365 Admin Center (https://admin.microsoft.com/#/SharedMailbox) and create a new shared mailbox.

Click the Add a shared mailbox button and fill the required fileds.
I have named my mailbox Cusomter Review Mailbox and set the adress to feedback@tenantname.onmicrosoft.com.

Now you need to add members to the mailbox. Currently, the only member necessary is the user in whose context the flow will run.
Creating the mailbox completes the setup step. We are now ready to tackle the automation.

The automation

Now it is time to create the flow that runs a sentiment analysis on a customer submitted review.

Got to make.powerautomate.com and create a new Automated cloud flow.

My flows → New flow → Automated cloud flow

Give it any name, I have named mine Customer Review Sentiment Analysis.

As trigger select When a new email arrives in a shared mailbox (V2)

After the flow creation has been completed, configure the trigger and set our shared mailbox address as Original Mailbox Address.
Further trigger configuration is not required.

Detect the language

The first part of analysing customer reviews is finding out in what language they where submitted. To do just that, create a new variable, call it obj_BodyLanguage, give it the type Object and set the value to the following JSON.

{
  "score": 0,
  "language": "en"
}

Add the Detect the language being used in text action to your flow and pass the Body of your trigger action as text.
The result of Detect the language being used in text is an array of languages each with a confidence score indicating how “sure” the AI is about this language.
We are going to iterate through all the results and if a results confidence score is higher than the score of our current obj_BodyLanguage, overwrite obj_BodyLanguage with the result.
In the end we will have the language with the highest confidence score set for further usage

Analyse the sentiment

Now that we know what language the text was written in, its time to run a sentiment analysis.
Add the Analyze positive or negative sentiment in text-action to the flow, set the language parameter to variables('obj_BodyLanguage')['language'] and the text parameter to the triggers Body.

The Analyze positive or negative sentiment in text action has multiple outcomes, and we are working with Probability overall text is negative, Probability overall text is positive and Probability overall text is neutral.
Scores are returned as two-digit decimals between 0 and 1 and all scores (negative, postive and neutral) summed up equal 1.
We are calculating the overal sentiment score using the following formular

Positive Score + (Neutral Score / 2)

We are dividing the neutral score by 2 to add its weight to both positive and negative.
This calculation results in a decimal number between 0 and 1 – representing the sentiment percentage.

Add a Compose action that runs the following formula to calculate the overal score.

add(outputs('Analyze_positive_or_negative_sentiment_in_text')?['body/responsev2/predictionOutput/result/documentScores/positive'],div(outputs('Analyze_positive_or_negative_sentiment_in_text')?['body/responsev2/predictionOutput/result/documentScores/neutral'],2))

Store the data

With our sentiment analysis complete, let’s store the results in SharePoint for future analysis and reporting. We’ll add a Create item action to our flow that saves each review with its calculated sentiment score.

Configure the action as follows:

Select your Customer Reviews site as the target SharePoint site
Choose the Customer Reviews List we created earlier
Map the following email data to their respective columns:

Title: Mail subject line
From: Sender’s email address
Body: Full review text
Score: Calculated sentiment score from our previous step

Remember to save your workflow and test it by sending a few sample reviews to ensure everything works as expected.

Wrapping up

The complete workflow should look like the following screenshot

Thats it. Every mail received will be processed and the sentiment score will be safed.
There are a lot improvements that can be done to improve our application but thats no content for this guide.

You could

Add custom column formatting
to the score column in the reviews list, to render the percentage a different way, maybe as stars that get filled based on the score.

Notify all team members
Make the teamsite available in teams and add notifications.

Incorporate planner
Bad reviews could lead to automatic planner task creation for our customer review team.

…and so forth.

Kommentare

Leave a Reply

Your email address will not be published. Required fields are marked *