Highlight

Building brand visibility requires a lot of effort. Analysis of social media reactions is key aspect of this process. With Azure Cognitive Services Text Analytics API companies can start analyzing feedback right away with ease.

In this article learn how to leverage Text Analytics API to analyze sentiment of tweets with later notification to Microsoft Teams. All this in couple of minutes using Microsoft Azure and Flow.

Prerequisites

Microsoft Teams Microsoft Flow Microsoft Azure Twitter Account

Instead of reading you can watch!

Different people prefer different medium so feel free to watch!

Watch on youtube

Prepare the environment

For flow to work developers must have following setup done. If below is already set up then this section can be skipped.

Team defined in MS Teams Azure Cognitive Services Text Analytics API keys Twitter account for testing

Step by step

Log in to Microsoft Teams at teams.microsoft.com Create Microsoft Team Account Give name to a team and set it to private Create Twitter Account (optional but good for testing) Log in to Azure Portal at portal.azure.com Add create Text Analytics API Provide properties for API Go to Text Analytics API and click on Keys blade Copy the Key 1 value

Create the flow

Open Microsoft Flow Portal at flow.microsoft.com Open My Flows tab Click on +Create from blank button Select first step ‘When a new tweet is posted’ Type in sentence or hashtag for analysis. For purpose of this demo #MarczakIOTester was used. In cases of companies it’s usually hashtag with their company, products or events names. Add new step Find Text Analytics - Detect Sentiment step Define new Text Analytics API connection Copy paste the Key and provide the Site URL. For site URL go to Text Analytics API Overview and copy paste the API endpoint. Add new condition step with following parameters

Left Value : Detect Sentiment -> Score

: Detect Sentiment -> Score Condition : Greater Than

: Greater Than Right Value: 0.5

In ‘If yes’ condition add an Teams - Post Message action And supply Post Message Action with values

Team Id : Name of the MS team where sentiment analysis results will be posted.

: Name of the MS team where sentiment analysis results will be posted. Channel Id : Team Channel name to post message to. General is default channel created for every team.

: Team Channel name to post message to. General is default channel created for every team. Message: Message that will be posted. In case of this demo ‘A positive sentiment for tweet [Tweet Text] sent by [Tweeted by] with score [Score]’

In ‘If yes’ condition add an Teams - Post Message action And supply Post Message Action with values

Team Id : Name of the MS team where sentiment analysis results will be posted.

: Name of the MS team where sentiment analysis results will be posted. Channel Id : Team Channel name to post message to. General is default channel created for every team.

: Team Channel name to post message to. General is default channel created for every team. Message: Message that will be posted. In case of this demo ‘A negative sentiment for tweet [Tweet Text] sent by [Tweeted by] with score [Score]’

Hit Create Flow button

Test The flow

Open Twitter at twitter.com Post negative and positive tweets for testing. Remember to add hashtag In couple of minutes (between 1 and 10) check flow for recent flows. In case of this demo it took 3 minutes to trigger flows. Check MS teams for flow results

That’s it for Today. Next time check how to upload tweet results to Power BI. Stay tuned!