Using APIs with Microsoft Flow

Most modern cloud-based software provides APIs to enable you to connect to your data and integrate with the software as required. Microsoft Flow is a great tool to help connect to these data sources to automate repetitive workflows and tasks. Outside of the wide range of default connectors that are available, Microsoft Flow provides the flexibility to connect to any API utilising the HTTP action within Microsoft Flow, and can even be triggered by ‘listening’ to a third party webhook that would conduct a HTTP Post request to your Flow.

Some examples of internal business process that we have automated, that you might consider doing as well, include:

  1. Creating and sending scheduled weekly summaries or reports
  2. Triggering business processes such as beginning the finance process when a sales opportunity is closed
  3. Following up on overdue sales opportunities in a CRM

This is a multi-part series, on how we at Engage Squared use Microsoft Flow to integrate with third-party APIs and how you can benefit from this approach.

In this article, learn how to connect to a simple API and send compliments to your co-workers every Friday morning by following the step by step guide below.

Triggering the Flow

All Flows begin with a trigger. Flow provides hundreds of trigger options,
Including a HTTP webhook that is triggered by real time information.
To keep our Flow simple, we use a ‘Recurrence’ trigger.
 Recurrence Action - Microsoft Collaboration - Engage Squared

Finding an API

Next, we would need to find an API we wish to connect to. There is a nice compliment generator here
Here we can find the following:
Sample Payload:
{ “compliment”: “9 out of 10 doctors say you have fairly heavenly clothes” }
Compliment as a Service API - Intranet Consulting - Engage Squared

Making a HTTP call

Going back to our flow, we will need to add an action to call this API.

Click the ( + ) button and add a new ‘HTTP’ action.
Set the Method as GET.
Set the URI from above ( )

HTTP Get - Microsoft Collaboration - Engage Squared

Parsing the HTTP call response

The HTTP action will send your request to the API endpoint and then return with a response in JSON format.

Add a ‘Parse JSON’ action that will help transform the response from the HTTP GET call into something more meaningful. To do this we add the “Body” from the HTTP GET call as the content. Flow makes this content available to us in the dynamic content selector.

Parse JSON Dynamic Content Schema Generated - Microsoft Collaboration - Engage Squared
Once we have selected the content, we would need to provide a schema which will act as a key to translate the response into usable variables in the form of dynamic content.

The easiest way to do this is to click on the ‘Use sample payload to generate schema’ hyperlink at the bottom of the action card and then paste in the sample payload from earlier in the following pop-up.


JSON Generate Schema - Intranet Consulting - Engage Squared
Flow will do the heavy lifting and do its best at converting the sample payload into a schema.  Parse JSON Schema Generated - Microsoft Collaboration - Engage Squared

Using the data

At this point we can use the data that is parsed through to automate any business process we want. For this example, we are going to keep things simple and send the compliment as an email.

Use the ‘Send an email’ action, providing the ‘To’ address, Subject and Body of the email, including our compliment – again using the dynamic content selector, this time to select our compliment from the Parse JSON step.

 Send an Email - Intranet Consulting - Engage Squared
Save and test the Flow to make sure that everything works.  Your Flow Ran Successfully - Microsoft Collaboration - Engage Squared

Collapsed Flow -   Microsoft Collaboration - Engage Squared

And then check the results in Outlook!  Result Email - Microsoft Collaboration - Engage Squared

Once we are happy with the Flow, make sure to give the Flow, triggers and actions meaningful names and leave comments where necessary!

JSON Add Comments - Intranet Consulting - Engage Squared

Wrapping up

This is a very simple example of how to connect to a third-party API, make sense of the response and use the response in a subsequent action. With Microsoft Flow, we can build upon this to meet much more complex business needs with useful automation.

So, unless your job is as simple as sending compliments to your coworkers every Friday, I would suggest checking out the next blog post on how to automate your job, one scheduled report at a time!

Leave a Comment

Your email address will not be published.