Build Intelligent Outlook using Azure
Tags: azure, logicapps, twilioquest, azurefunctions
Published: 2021-03-31 07:30:58


##**What problem are we trying to solve today?**

Consider you are working for a company where they restricted access to outlook in your mobile or Consider you don't want to sync professional mail in your mobile. In either cases there might be a possibility where you will miss to respond back to an escalation mail or feedback mails on time .

<img width="4096" src="https://media4.giphy.com/media/jqH5YwZOF8RQ7pUBei/giphy.gif?cid=ecf05e47ctwm0a4gnopymxqk6ajo0u2hdtkqq19gvnvugrz3&rid=giphy.gif" />
-------------

##**Proposed solution :**

1) We don't want to be disturbed for regular mails 
2) We should make our outlook intelligent enough to know that we are only interested in escalation or feedback mails. Right now outlook can't categorize mails based on these sentiments of the contents. 

So in this post, we will see how to make our Outlook intelligent enough to send out a message to our personal mobile number whenever there is an escalation / suggestion mails addressing to us.

<img width="4096" src="https://media0.giphy.com/media/3ohrypQkRlLBKgfYY0/giphy.gif?cid=ecf05e475vbtunqemk1ls8ee42ngnyrz3gbhsblp4rxnk0oq&rid=giphy.gif" />

-------------

##**Prerequisites :**

- Azure Logic apps
- Azure Functions
- Azure Cognitive services
- Twilio 

-------------

##**Architecture :**

<img width="4096" src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e166x84cuyitgpowntkv.jpg" />


##**Steps to implement workflow :**

- Go to Azure portal : <a href="https://portal.azure.com"> portal.azure.com </a>
- Get free azure subscription here : https://azure.microsoft.com/en-in/free/

##**Logic Apps workflow :**

- Choose your subscription and create Logic apps
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwo3zipnwxb5yd073esf.png)
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yobbtkxs4d7k0rw9bxu9.png)
- Once logic app is created open the designer view 
 
 ![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abha6netaq5ai6otrox6.png)
- Select Blank Logic app

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/692qjgzs4unuhsjkxrtf.png)
- Search for Outlook in connectors and triggers and select trigger "When a new email arrives (v2)"

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zx9njleeq8uo3az9wrsh.png)
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/535zdcp0ny7vl8jjbi3r.png)
- Mention your mail id in "To or CC" condition 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfbkj9c12il6ewfzgq8j.png)
- In the next step choose Text Analytics as an operation and choose Detect sentiment (v2) as action , so that we can detect sentiment of the content of the mail

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8dp4jl4zqpgxo1r045r.png)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwjfpg6ph3uu6y4djzm5.png)
 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cg10dbbm4fn6ubnxwa7g.png)
- In the next step choose Azure function to categorize each sentiment score and in the request body point it to the documents of the sentiment analysis response

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0iejshtmmok8xw9qn2n3.png)
 ![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpdl6bzamry6z687lier.png)

- Now add condition based on the response of the azure function and if the response is ASAP or NEUTRAL , then send a text message to your registered number in Twilio account

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ceh6de6zsbhv9otsbuop.png)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojwhz11rfjh9buy59o7b.png)
 
 

##**Azure function workflow :**
 
Based on the sentiment score , we will use azure function to categorize the content of mail that we receive. 

Preview of the mail that we sent in earlier step: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12dqctj4itfr9jn94iw8.png)

## Request to sentiment analyzer :

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtwy8hzvvflx9d7oeln7.png)

## Response from sentiment analyzer :

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixqmbv6we6jx7q33m22q.png)

 
And based on the below code snippet we will categorize the above mail as Negative and will tag it as ASAP message and send response back to logic app

 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pciihpyd3xskgvfgzzh.png)

##**Twilio workflow :**

- Once we got response from Azure function it will be send to Twilio workflow based on two conditions , It will check if the response is either ASAP or NEUTRAL . In either of these case we will trigger a message to our configured number in the portal as below

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vcfjarp993oky7q2sjce.jpg)

##**Act on negative feedbacks ASAP:**

<img width="4096" src="https://media.tenor.com/images/79cdc2b071a19135dc3630eedf374d30/tenor.gif" />


- Finally, we made our outlook intelligent enough to send notifications on negative feedbacks from our client 

<img width="4096" src="https://media1.giphy.com/media/lTRuG1F4VZ3LHMpXY2/giphy.gif?cid=ecf05e47ho85lar7uk3saedg55m4eec17p0cvw5cfezraj3a&rid=giphy.gif
" />

##**Github Source code:**

https://github.com/Divakar-kumar/SentimentWebhooks.Outlook



##**Further steps:**

Please go ahead and fork the repository to make your outlook more intelligent, where you can implement custom logics based on the sentiment score. 

<img width="4096" src="https://media1.tenor.com/images/3f6aef9534dec220452cfa74d2ec2476/tenor.gif?itemid=18621612
" />