Sending a Reminder Email

In this section, we'll check the weather forecast and send our user an email, reminding them to save for a rainy day. We want to encourage good savings behavior in our users with innovative notifications. And to ensure that it works correctly, we'll need the Azure Logic App from the second example. Let begin by implementing the following steps:

  1. Open your Logic App in the portal and click on Edit. The Logic Apps Designer will be shown.
  2. Check that you are in designer view, not code view.
  3. Click on the + icon below your HTTP request trigger. Click on Add an action. Search for Weather in the search box, and select Get the forecast for tomorrow.
  4. Choose your Location and whichever Units you are comfortable with. We will be using percentages, so it doesn't matter whether you use the Metric or Imperial System. We could query our user database for their location.
  5. Click the + button below your weather box, and then click Add a condition.
  6. Place your cursor inside of the left-hand box and search for Rain Chance in the Dynamic content box that appears. Refer to the following screenshot:
  1. Set the condition to Greater than, and enter 0.9 in the right-hand box. This will trigger if the chance of rain tomorrow is greater than 90 percent.
  2. Your Logic App will now display paths for the true and false conditions.
There are lots of different logical constructs in Logic Apps, but one thing to remember is this: if you find yourself using a massive switch statement, or logic-forking more than a couple of times, then you need to split your Logic App up. It's important that your logic app stays simple, you can split complex ones up into either more logic apps or Azure Functions. The reason for this is that they were originally designed to be relatively simple, and they quickly become unmanageable once they grow beyond a few true/false branches.
  1. Add an action to the True fork and search for email.
  2. There are a lot of connectors; the main ones are Gmail and Outlook. If you select Send an email, the email provider will ask you to sign in. If you already have an account with one of them, then sign-in to it. If you don't have one sign up for a free account with one of them.
  3. Set the To field to an email address that you have access to. Set the Subject to Save for a rainy day!
  4. In the body of the email, you can add some dynamic content. It'd be great if we could use content from our request in the same way that we used the data from the weather forecast, and luckily, we can. Click on the HTTP request trigger, and click Generate schema from example payload. Copy and paste a transaction payload from Postman.
  1. Click in the body of the email and search for amount in your Dynamic content menu. Now that there's a schema, we can use this data. Insert it. Write a message similar to the one in the following screenshot:

This is a tricky Logic App to test, unless you live somewhere very rainy! So, let's cheat and set the probability of rain forecasted to be higher than to 0. Then, send another transaction from Postman.

You have successfully created a Logic App with logical conditions, schema, and dynamic content, and you have sent an email based on live weather conditions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.104.124