SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

The Sentiment Analysis API evaluates text input and returns a sentiment score ranging from 0 (negative) to 1 (positive). This is useful for detecting positive and negative sentiment in social media, customer reviews, and discussion forums.

The Sentiment Analysis API provided by Microsoft evaluates the text input and returns a sentiment score for each document, ranging from 0 (negative) to 1 (positive). This capability is useful for detecting positive and negative sentiment in social media, customer reviews, and discussion forums. In this article, I am going to show you how to send the feedback entered in a SharePoint Online modern list item to Sentiment Analysis API and update the response back in SharePoint. Also, I am going to show how to beautify the sentiment score with emojis using column formatting feature.

Create a SharePoint list with the following columns.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow 

At the top of the list, click Flow, and then click "Create a flow".

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow 

Select the below flow template from the right-hand panel.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Follow the instructions on the Microsoft Flow site to connect to the list we have created. Credentials will be verified for each service used in the flow. For Office 365 services such as SharePoint and Outlook, connections will be created automatically. The next steps will be performed in the Microsoft Flow designer. The first action displayed, also known as a trigger, will determine how the flow will be started. Additional actions may be added after the first. Each new action will be dependent on the previous action.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Next step is to add an initialize variable action to set the value of the current Item Id.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Create a POST request using an HTTP action. Set the HTTP Method, URI, Headers, and Body as shown below.

Note
Login to Azure and get the Ocp-Apim-Subscription-Key. Refer to this article for steps.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Now, let us parse the sentiment score from the response we received from the HTTP action and save the value in a variable using "Initialize Variable" action as shown below.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Expression : body(‘CallSentimentAPI’)[‘documents’][0][‘score’]

Here, CallSentimentAPI is the HTTP action name.

Let us update the sentiment score in the list item using a "Send an HTTP request to SharePoint" action, as shown below.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Save the flow and go back to the list.

Let us create a new item in the SharePoint list to check the sentiment score for our feedback.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

If all goes well, we should see the sentiment score in the list column.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

We can check the status of every execution in the flow history as shown below

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

To beautify the sentiment score with emojis, we can use the SharePoint column formatting feature as shown below.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

I have used the following column formatting formula to convert the sentiment score into emojis.

SharePoint Online - Analyze User Feedback Using Sentiment Analysis API And Microsoft Flow

Hope you liked this post. If you have any questions on SharePoint or office 365, please let me know.