Consuming a Webhook with Azure Logic Apps

In the world of technology services, integrations are the gold standard. Azure Logic Apps are an accessible and customizable way to create basic integrations. One of the most common integration options you will see is a “webhook” – when a system sends defined HTTP requests to a user-defined endpoint.

This post summarizes an example where when a visitor logs in at an Envoy kiosk, the integration sends an SMS and an automated phone call to their host through Plivo. Azure Logic Apps can be used to quickly create an endpoint for receiving webhooks without writing code.

Create a New Logic App

Create a new Logic App in your Azure Portal, selecting “HTTP Trigger” as the first step in the designer.

Catching a Sample Hook

Without adding any other steps in the Logic App designer, save the workflow to get a URL assigned to the HTTP trigger. This URL can be handed off to the service we’re integrating with – in this case, Envoy visitor management. In Envoy, we define the event that triggers the webhook to be called as “Entry sign-in.”

After triggering the event, in this case a visitor signed in at the kiosk, we can view a sample of the body sent by the service. Under the “Runs History” on the Logic App’s overview, you can access the details of the sample event. Examine the JSON within the body element to determine or verify the data structure being sent from the service. Some services will offer documentation for their webhooks, others do not. (Sometimes the documentation is just too hard to find or navigate and catching a sample is faster)

Define Incoming Schema

Use a sample payload to generate a JSON schema

Part of the ease of use for Azure Logic Apps comes from the use of tokens for input fields in the designer. To more easily generate these tokens for the incoming webhook content, we need to declare a JSON schema that matches the incoming service.

The most expedient way to create this schema is from an example webhook body. Grab a sample webhook body, such as the one we accessed in the previous section, and input it in the Logic App designer in the “Use sample payload to generate schema” dialog.

The Logic App designer will parse the sample content and input the schema into the HTTP request trigger element. This schema can be further customized as needed, but for now, we are ready to use the elements in additional steps in our Logic App.

Build Your Functionality

From here, we can add steps to the Logic App to complete the action(s) that we would like to happen. In this case, we want the Logic App to trigger an SMS message and phone call to phone numbers we have stored in Office365. We’re going to look through the connectors provided in Logic Apps to perform these functions for the convenience factor. When we need functionality beyond the many available connectors, we’ll issue a direct HTTP request.

Overview of the Logic App designer steps

To accomplish the aim of this Logic App, we will need the following connectors:

  • Office365 Connector – get user profile
  • Plivo – send SMS
  • HTTP – send POST request for custom Plivo phone call with a recording played on answer

Using additional services such as Plivo can incur additional costs, so be sure to check with the connector type as well if the service will bill you directly.

Customizing the Plivo Action

Configuring each of the steps is usually a brief form in the Logic App designer. In most cases, the first task to configure an action is to input credentials for that service. In the case of Plivo, we need to input the authorization ID and token from our account – conveniently located on the Plivo dashboard.

Connections setup
Plivo dashboard

Once connected, the step can be customized to perform the specific action we’re creating. In this case, we’re sending an SMS text message to let a user know that their visitor has arrived.

Plivo connector with O365 and HTTP request outputs in the form

Each field for the action can have previous input/outputs used as the whole value or part of the value. We use the mobile phone number retrieved from Office 365 and created an exciting text message to let the user know that someone has arrived. We can include the visitor’s name by using the full-name token from the HTTP request.

You can find the details on each field for the connectors you choose for your actions within the extensive Connectors documentation.

Wrapping Up

Integrations are the gold standard of technology services because they allow us to quickly and nearly invisibly connect multiple services together into a cohesive solution. The user’s experience with a solution is a foundational measure of the value of a technology, and without integrations, services can be left disjointed. Azure Logic Apps offer a low learning curve for anyone who wants to receive webhooks from various services. Not only do they allow anyone to build integrations, but the cost per execution is fractions of a cent. Whether for personal use, small business, or enterprise, Azure Logic Apps can assist in consuming webhooks.