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

  1. Microsoft Teams
  2. Microsoft Flow
  3. Microsoft Azure
  4. Twitter Account

Instead of reading you can watch!

Different people prefer different medium so feel free to watch!

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.

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

Step by step

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

Create the flow

  1. Open Microsoft Flow Portal at flow.microsoft.com
  2. Open My Flows tab
  3. Click on +Create from blank button
    Optionally selecting from template also works. There are templates set up exactly for this purpose. Sometimes they can be outdated so it is recommended for production use to build flow from scratch.
  4. Select first step ‘When a new tweet is posted’
  5. 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.
  6. Add new step
  7. Find Text Analytics - Detect Sentiment step
  8. Define new Text Analytics API connection
  9. Copy paste the Key and provide the Site URL. For site URL go to Text Analytics API Overview and copy paste the API endpoint.
  10. Add new condition step with following parameters
  • Left Value: Detect Sentiment -> Score
  • Condition: Greater Than
  • Right Value: 0.5
  1. In ‘If yes’ condition add an Teams - Post Message action
  2. And supply Post Message Action with values
  • Team Id: 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.
  • 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]’
  1. In ‘If yes’ condition add an Teams - Post Message action
  2. And supply Post Message Action with values
  • Team Id: 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.
  • 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]’
  1. Hit Create Flow button

Test The flow

  1. Open Twitter at twitter.com
  2. Post negative and positive tweets for testing. Remember to add hashtag
  3. 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.
  4. Check MS teams for flow results
    Notice how sure bot is about the results. First tweet got result of 98% that it’s positive and second one 99.99% that it’s negative.
That’s it for Today. Next time check how to upload tweet results to Power BI. Stay tuned!

Adam Marczak

Programmer, architect, trainer, blogger, evangelist are just a few of my titles. What I really am, is a passionate technology enthusiast. I take great pleasure in learning new technologies and finding ways in which this can aid people every day. My latest passion is running an Azure 4 Everyone YouTube channel, where I show that Azure really is for everyone!

Did you enjoy the article?

Share it!

More tagged posts