Azure Logic Apps: automate your email replies with ease

Image for post
Image for post

Si quieres leer la versión en Español de este artículo, haz click aqui.

With Azure Logic Apps, you can quickly build scalable workflows that integrate apps and data of several cloud services and on-premises systems. This post is the second delivery of a series of posts about Azure Logic Apps:

  1. Intro of Azure Logic Apps.
  2. Easy connecting with know services and send automated replies to emails, based on customized criteria defined by you.
  3. Automating repetitive job tasks to increase productivity.
  4. Connecting to different Public Social APIs to develop a piece of your app.

In this post, you will learn how to develop a fully-working application in just a couple of minutes.

“Thanks, but no thanks” email reply

Imagine that you want to resolve the following situation:

Everyday I get tons of automated emails from job recruiters asking me to start a lengthy process to get a job that, after reading the first line, I notice I’m not qualified to. I’d like to reply to every one of them explaining why I believe I’m not the best fit, but I don’t have the time to do it.

Have you ever been in this situation before? In my case, I receive multiple jobs offer for a Senior iOS Developer, and I have zero experience in the field! And instead of politely answering each one of these emails, why don’t we create an app that will automatically reply with a “Not interested” message when receiving a Senior iOS Developer job offer in our inbox (or similar).

Of course, you can solve this hassle in many ways, but _using an automated solution, you will do it right and only once_. To do so, you first have to analyze the problem by dissecting it into little, manageable pieces. In this case:

  1. Create an app that “starts” when an email is received into your email account (e.g. Gmail).
  2. This app inspects the email content (subject, body, or both) checking if it contains a specific set of keywords (e.g. “Job opportunity” in the subject and “Java developer” or similar in the body).
  3. Send a reply to the sender of the original email respectfully declining the offer, using a predefined message like Thank you so much for considering me for this position. However, I believe I’m not the right candidate for the job. Please let me know if there is a future opportunity best suited for my current skills and expertise. You can find my CV here: <link-to-your-CV>.

Although it seems much work just for sending an email reply, with Azure Logic Apps you can create this app in minutes.

Creating Azure Logic Apps

Navigate to the Azure Portal.

In the left pane, click the Create a resource button and search for Logic app, or click here. Name your new logic app, choose a subscription and click the Create button.

Image for post
Image for post

Once your app is created, navigate to its home screen. Scroll down and choose Blank Logic App under the Templates section.

If you want to see a great step-by-step walkthrough of Azure Logic Apps, go here.

Image for post
Image for post

Now you are in the Logic apps designer. As we mentioned earlier, your app needs to start when an email arrives in your Gmail account. For this, you need to create a Gmail Trigger. You do so by typing “gmail” and choosing the first option you see below.

Image for post
Image for post

The only operation that is available is “When a new email arrives”. This is the one we need.

Image for post
Image for post

Click Sign in to connect your Gmail account with this app.

Image for post
Image for post

Add a new Subject parameter to filter out all emails that don’t have the words “Job opportunity” in it.

Image for post
Image for post

Notice that the app is configured to poll your email inbox every 3 minutes searching for new emails that match these criteria.

Next, we need to add a condition to identify the emails that contain a predefined set of keywords inside their bodies. For this, click the + New step button, then click the Built-in tab, choose the Control option and finally pick the Condition card.

Configure an “AND condition” to check if the Body contains the phrase “Java developer”, as shown in the image below:

Image for post
Image for post

Finally, add an action inside the If true section to reply with the best polite predefined answer you can come up with. I recommend you to use the Send email (V2) connector as it uses a simple but yet powerful WYSIWYG editor.

Image for post
Image for post

And that’s pretty much it. Click the Save button located in the top toolbar and then click Run to activate the app. Try sending an email to yourself to validate that everything works.

If it does, you will see something like this (pretty neat, right?)

Image for post
Image for post

I didn’t lie. This could take you up a couple of minutes, but no more than that. Can you provide a rough estimate of how long it would take you to code the same app with the language of your choice? For sure, it will take much more (if it doesn’t, send me a DM, we are hiring :D)

Under the hood

If you need to develop this from scratch, regardless of the language or framework you use, your code will have to cover the following topics:

  • Interact with the Gmail API to list the latest emails and send a reply email. To implement this part, you will have to read the documentation of this API and test out these endpoints a few times.
  • Connect to the end-users’ email account on their behalf using the OAuth 2.0 protocol. Azure Logic Apps uses the Authorization code grant type.
  • Run periodically (every X minutes). You can either code this, execute a cron job, or else. But you must guarantee its periodical execution somehow.
  • Contain business logic to cover some dynamic conditions based on configurable keywords.
  • It has to be redeployed automatically on every code change.

Now that you have read all of this, how long would you think it would take you to develop the app? And, how long do you think it would take to a developer with little/no expertise in any of these topics? Definitely more than a couple of minutes, right? And one more, what would happen with your estimations if we now want to use Outlook instead of Gmail?

As you see, Azure Logic Apps is the right choice for rapid development with little or no code, even for novice or advanced developers. In the next posts, we will analyze more capabilities of this Azure Service by implementing new use cases. Stay tuned!

🎉🎉

Written by

I like to create things, therefore I code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store