Understanding Logic Apps On Microsoft Azure

Logic Apps help you to build complex workflows in simple steps using any of its 200+ connectors. As the Logic Apps are serverless, you do not need to worry about server sizing. The platform will scale to meet your demand and you will be charged only for what you use. Logic Apps provide a drag and drop developer experience in which pretty much any level of a developer can drag shapes on to a UI and create a really powerful solution.

This article will show you how you can build a logic app that checks Twitter to detect negative feedback and get a mail on receiving one.

Connectors to be used,
  • Twitter connector to monitor twitter feed for a new message is posted with a specific hashtag
  • Cognitive Services, a service inside Microsoft Azure, to do sentiment analysis on the text which returns a value between 0 and 1 as to the positive or negativity
  • E- mail connector in order to send an email

 

Here, in this tutorial, the logic app is going to be triggered when a new tweet is posted with the hashtag, #LetsLearnLogicApp.

Step 1

Log in to your Microsoft Azure portal, click on "Create new resource" and select Text Analytics API from AI + Cognitive category to enable sentimental analytics. Enter the Name, what Subscription you want it to belong to, what Pricing Tier and the Resource Group you like. Here, we are creating a new resource group. Wait for a few minutes for that to be created.

Azure 

Step 2

Once the deployment has succeeded, open the resource and obtain the Keys, to interact with this service. You will be having a primary and a secondary key where you can regenerate both in case one is compromised. Take note of any key to be used in the Logic App

Azure 

Step 3

Create a Logic App, from the Web + Mobile category. Give it a Name, set your Subscription, and here we are using our existing Resource Group in the same Location. Click on Create and wait for few minutes.

Azure 

Step 4

Once the deployment is completed, open your Logic App, which will take you right to the Designer.

Azure 

Step 5

Select the "When a new tweet is posted trigger" from the common trigger which will create a logic app that already uses the Twitter connector as our trigger.

Azure 

Step 6

Sign in to your twitter account using your credentials, authorize the logic app to work with the twitter account and click on continue and provide the Search Text there. Here we are going to monitor hashtag #LetsLearnLogicApp and we can define how often it wants to check for the items, which we are going by default.

Azure 

Step 7

Now we have to take the response from Twitter and run it through our Text Analytics. Add an Action in the next step and search for cognitive and select Text Analytics and select Detect Sentiment

Azure 
 
Azure
 
Azure 

Step 8

Give a Connection Name and paste the Account Key from Text Analytics service that we created in the first step and the Site URL which also can be obtained from the overview tab of the cognitive service you created. Click on Create and finish configuring this action by telling it what Text I want it to analyze, which you have to select the Tweet Text from the dynamic content which will be populated based on the previous actions.

Azure 
 
Azure 

Step 9

Now we have to add a condition, only to mail in case of any negative sentiment as until now it will just return the score of the sentiment which is a value between 0 and 1, where closer to 0 tends to have a more negative sentiment. Click on Add a Condition as the next step and choose the value Score and the operator to be less than and provide the value 0.5 to be checked with the score value.

Azure 

Azure 
 
Azure 
 
Step 10

On the condition true, Add an Action and search for Office 365 and select the Office 365 Outlook connector and select Send an email action

Azure 
 
Azure

Step 11

Sign in and create the connection using your credentials. Here I am using one of my other email accounts for this demo for the To address, specify the Subject and in the Body, I'm going to link the username of the Twitter account and the score of the sentiment. Save the Logic App

Azure 

Step 12

The complete workflow should look like this. Post a tweet and check yourself. Please check for emails in junk folder also if not found in Inbox.

Azure 
 
Azure


Similar Articles