Text Sentiment analysis from Azure Logic Apps

Spread the love

Azure Logic Apps is a cloud service that is used to schedule and automate tasks and create workflows using an easy to use graphical designer. It comes with hundreds of ready-to-use connectors, which include services such as Azure Service Bus, Azure Functions, Azure Storage, SQL Server, Office 365, Dynamics, Salesforce, BizTalk, SAP, Oracle DB, file shares, and a lot more for any business need. If any of you have used Power Automate (previously Microsoft Flow) you will see there are several similarities, however, they are two separate services. See this Microsoft article to help you Choose between Logic Apps, Functions, WebJobs, and Power Automate. In this tutorial, we will see how to create a simple Logic App that reads tweets and analyses text by using Cognitive Services’ Sentiment Analysis.


Before you get started. familiarize your self with some terms from the Microsoft Docs.

  • Workflow: Visualize, design, build, automate, and deploy business processes as series of steps.
  • Managed connectors: Your logic apps need access to data, services, and systems. You can use prebuilt Microsoft-managed connectors that are designed to connect, access, and work with your data. See Connectors for Azure Logic Apps.
  • Triggers: Many Microsoft-managed connectors provide triggers that fire when events or new data meet specified conditions. For example, an event might be getting an email or detecting changes in your Azure Storage account. Each time the trigger fires, the Logic Apps engine creates a new logic app instance that runs the workflow.
  • Actions: Actions are all the steps that happen after the trigger. Each action usually maps to an operation that’s defined by a managed connector, custom API, or custom connector.
  • Enterprise Integration Pack: For more advanced integration scenarios, Logic Apps includes capabilities from BizTalk Server. The Enterprise Integration Pack provides connectors that help logic apps easily perform validation, transformation, and more.


  1. You need an Azure Subscription. If you don’t have an Azure subscription, create a free account before you begin.
  2. A Cognitive services Key and EndPoint. To create one follow this tutorial Create Cognitive Services Key for all APIs in the Azure Portal

Get Started

Open the Azure Portal and search for Logic Apps

Fill the required fields and click Create.

As soon as the resource is created, go to resource. Open the Logic App Designer from the menu on the left.

Now you have to choose a trigger. From the screen choose When a new tweet is posted. You will see the trigger added to the designer screen. Click to enter your Twitter account. This will open a separate window. As soon as you authorize Logic Apps with Twitter you will see the connector with your account credentials.

As soon as you connect your account click on the trigger to add the parameters for the trigger to run. I set it up to check for tweets containing the hashtag #codestories every hour. You can add additional parameters such as Time Zone or Start time.

To add a new Action click continue. To add the Sentiment Analysis action type Sentiment in the search box and find the Detect Sentiment action. Click to add it to the designer.

Here you will need your Cognitive Services or Text analytics key and EndPoint. Add them to the connector.

Now that you have created the Detect Sentiment action click to complete the parameters. Choose Text and from the Add dynamic content link on the bottom choose the Tweet Text  as the text to analyze. You can also add the Language but that is optional.

That is it! In order to see the result, I proceeded to create a Send Email action from Office365 to send me the tweet and the analysis result, but you can continue your process in any other action as you like. Let’s see the Send Email action. Click New Step to add a new step. From the search box find the Send an email action and add your Office365 credentials. After the connection has been completed complete the action parameters as follows.

Then Save the workflow and click Run from the bar on top.

Right away I published a tweet with #codestories hashtag to test my workflow.

The trigger run and executed successfully since I can see ticks in all my actions. Do not wait too long to test because the testing period will time out.

If you open those actions you will see a lot of information on what went wrong and the execution details. You can see the inputs and outputs and useful information to debug the app.

After I went to my inbox and there it was. The email the app sent me with the tweet and its score!

This was a simple flow with a few steps.  Logic Apps can be as small or as big and complex as you like and support variables and branching to help you create any workflow that you want.

Leave a Reply

Your email address will not be published. Required fields are marked *