Written by

Joseph Velliah

Share

  

Category

see all categories
intranet as a service

SharePoint Online – Analyze User Feedback using Sentiment Analysis API and Microsoft Flow

The Sentiment Analysis API provided by Microsoft evaluates 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

Create SharePoint List

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

Create flow

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

select-flow-type

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.

add-new-step

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

setitemid

Create a POST request using a 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 this article for steps.

callsentimentapi

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

setsentimentscore

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

Here CallSentimentAPI is 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

update-list-item

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

new-item

If all goes well, we should see the sentiment score in the list column as shown below

data

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

status

success-run

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

column-formatting1

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

formual

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

Joseph Velliah

Written by Joseph Velliah

Joseph Velliah is Hubfly’s Head of Delivery. In this role, Joseph leads the development, implementation and delivery of our products to expand Hubfly’s global delivery capability and to identify new delivery and operational methods that will enable our clients to be successful in their digital transformation initiatives. An important part of this role is focused on helping Hubfly and our clients define and enable the workforce of the future that will enable and sustain the digital economy. Joseph received his first Microsoft’s MVP award in April 2017 for the Office Development Category.