Configuring a Webhook with Airtable

Airtable provides a platform for constructing and structuring databases for virtually any project imaginable. Its basic version is completely free and supports real-time collaboration with team members, making it an excellent tool for data organization.

In the following example, we utilize the Call Webhook action within a flow to retrieve sales agents based on their zip codes, as stored in a pre-configured Airtable database.

Construct Your Airtable Database

To integrate data into your flow via a Webhook, you must first create an Airtable account and build your database.

Shown below is a simple PID lookup database, which includes fields (comparable to spreadsheet columns) for the contact’s name and PID.

Build your Flow

Once your Airtable database is ready, you can proceed to design your flow. In our example, the flow begins by prompting the contact to provide their name for PID retrieval. Using the Call Webhook action, a request is sent to Airtable to fetch the relevant data from the database.

Please note that lookups in Airtable are case-sensitive.

Configuring the Call Webhook Action

First, generate your Call Webhook action:

Next, select the ‘GET’ method and enter your URL and HTTP Headers (details on locating these in Airtable are provided below).

The components of your encoded URL can be found in your database’s API documentation. Access this documentation by clicking HELP in the upper right corner of your Airtable account, then selecting “API Documentation”:

Then, navigate to the “Authentication” tab on the left side of the screen:

On this page, you will find the information you need for your URL, Header Name, and Header Value.

This page contains the necessary information for your URL, Header Name, and Header Value.

Note that the Header Name is “Authorization” and the Header Value is “Bearer” followed by your unique API key.

Here is how this appears in the Call Webhook action:

Configuring your URL

The URL consists of two parts.

The first part is provided on your Airtable authentication page. For our PID lookup database, it is:

https://api.airtable.com/v0/appxhoiUp1L9yAmke/Table%201?

The second part is encoded and slightly more complex. For our PID lookup example, it appears as:

filterByFormula=Name%3D%22@results.name%22

When decoded, the URL becomes more readable:

filterByFormula=Name="@results.name"

Creating your URL

The simplest method to create your URL is by using the Airtable Webhook Wizard. Here’s how it works:

Enter the following details into the wizard’s fields:

  1. Your base ID, found on the API page of your Airtable account. Access this by navigating to your base, clicking ‘Help’, then ‘API Documentation’.

  1. Your Airtable base name. In our example, it is ‘PID’.

  2. The column header you wish to lookup. For our PID lookup flow, we use the student’s name.

  1. The match type. Options include ‘Equals’, ‘Equals (case-insensitive)’ for values like leah or Leah, or ‘Contains’ for values that include the text, such as Aleah, Maleah, or Leah.

  2. The expression of the variable saved in your flow, written as @results.variable_name. Since we named our variable Name, we use @results.name.

  3. A checkbox for numeric values, if applicable.

  4. Max records, which defines the maximum number of Airtable records to return. Leaving this blank returns all matching records.

After entering all details, your final URL is automatically generated in the red outlined box.

If you prefer to write the URL manually, here’s how:

Begin the second part with a query string: filterByFormula=

It is simpler to write the URL with special characters and encode it afterward. For our PID lookup, the expression is filterByFormula=Name="@results.name". Here, Name refers to the “Name” field in the Airtable database, while "@results.name" refers to the flow variable saved in our lookup flow.

Combined, the decoded URL is:

https://api.airtable.com/v0/appxhoiUp1L9yAmke/Table%201?filterByFormula=Name="@results.name"

 

The final step is to encode the URL. Encoding converts characters into a web-acceptable format. Use Airtable’s URL encoder or a character encoding table. The final encoded URL is:

https://api.airtable.com/v0/appxhoiUp1L9yAmke/Table%201?filterByFormula=Name%3D%22@results.name%22

Important: The @ symbol must remain unencoded.

Here is how the Call Webhook action appears for our PID lookup flow:

Evaluating External Variables

After configuring your Webhook, you can use the @webhook.records variable in your flow, which references values returned from an external application via the Webhook.

To reference variables from your Airtable database, create a Split by Expression action that assesses one of the returned values against a response rule.

Below is our Split by Expression action for the agent lookup flow:

Split by Expression Inputs:

A – The operand used here is @webhook.records because “records” is the key Airtable uses to reference a database row. View your database keys by examining Webhook events as described here.

B – The response rule has only the phrase is optimal for this use case.

C – The value(s) your response rules will match against the operand. Here, we use [], indicating no matching data was found.

D – The category where contacts are placed if the operand matches the response rule. Categories pathways to new nodes, directing the contact onward. In this case, since no match was found, we inform the contact.

The final step is to send a message returning the PID:

Remember to use the @webhook.records variable to reference values from the Webhook. Use @webhook.records[0].fields.name to reference a field from your Airtable base.

In our example, @webhook.records[0].fields.PID references the PID. Note that fields correspond to spreadsheet columns.

Here is the final result:

Test the flow using the simulator:

Click the webhook link in the simulator to view your Webhook event.

For more details on configuring, testing, viewing Webhook events, and troubleshooting, click here. For additional support, message us via the widget in the bottom right corner.