Monitor social media with Microsoft Flow and the Azure Text Analytics API

A lot of marketing & communication departments use expensive tools to monitor their brands. These tools are handy, but they are pretty expensive, so a lot of companies would be eager to replace these tools with something cheaper.

How could you replace such a tool? Microsoft Flow is the answer for this! Since a while the Text Analytics connector is available in Microsoft Flow. This makes it possible to send text inputs to the Text Analytics API, which will return a score between 0 and 1. Of which 0 is very positive and 1 is very positive.

In this particular scenario, I will show how to create a Flow where we have three possible outcomes:

  • A negative text (score is 0.3 or lower)
  • A neutral text (score is between 0.3 and 0.7)
  • A positive text (score is 0.7 or higher)

Walktrough

Create a new Flow from blank and select the "When a new tweet is posted" trigger from the popular triggers.

Microsoft Flow will create a Flow for you where you can fill in a search text for the Twitter trigger. You can add a hashtag you want to follow. This could be very handy when you want to follow Tweets that are meant for special events.

Next, we'll add a action called "Text Analytics - Detect Sentiment". This is a way to call the Azure Text Analytics API. The Detect Sentiment part of this API is good at detecting if a text is positive or negative. There are loads of other Azure Cognitive Services APIs, make sure to take a look at them and try them out...

To make a connection with the Text Analytics API, you have to go the Azure portal and create a new resource. Make sure to search for "Cognitive Services", fill in the right properties and click create.

When the Azure resource is available, make sure to grab a key from the resource you have just created.

Back in the Flow creation screen we have to fill in the properties for the Text Analytics API Connector.

  • Give the connection a name
  • Fill in your Cognitive Services account key
  • Use a site URL if you are not using the West US region

Click create when you are done and make sure to add "Tweet Text" from the dynamic content panel. If you did everything right, you will see something like this:

Next we will have to use a condition for our different scenarios. First let's make sure to set the condition to score (the result from the Detect Sentiment action) is greater than or equal to 0.7. After that, add another condition in the "If no" branch of the previous condition. Set the second condition to score is less than or equal to 0.3.

Take a look at the image below how the conditions will play out:

The above conditions will make sure you can use different scenarios for the different outcomes. A very negative Tweet will probably need a different approach than a very positive Tweet. At one of my customers I used this scenario to fill a SharePoint list with the different outcomes. For the very negative Tweets I also added an action to send an email to a shared mailbox.

Final remarks

There are some really cool things possible with Azure Cognitive Services, make sure to take a look at the possibilities. This is just a tip of the iceberg!

Comments

comments powered by Disqus