[ADVANCED] HOW TO: Trigger Zaps instantly from Airtable

  • 1 December 2020
  • 20 replies
  • 2174 views

Userlevel 7
Badge +14

Q: Can Zaps be triggered instantly from Airtable?

A: Yes, read on…

 

Credits

Troy Tessalone is a Certified Zapier Expert at Automation Ace.

 

Background

Zaps with an Airtable trigger are NOT “instant” and can take up to 15 minutes to fire depending on your Zapier plan. They’re not ideal for certain use cases, especially when time is of the essence.

Here's how to get around that though!

Prerequisites

  • Zapier Paid Plan (needed to use Webhooks in Zaps)
  • Airtable Paid Plan (needed to use Scripts in Automations)

Apps

  • Zap with a Webhooks trigger
  • Airtable Automation with a Run Script action

First, start with the Zap...

Zap

GOAL: Create a Zap that has a ‘Webhooks’ trigger with a ‘Catch Hook’ for the trigger event.

Steps

Trigger: Webhooks - Catch Hook (The provided webhook will be placed into the Airtable Automation Script.)
Action: [Configure the rest of the Zaps action steps as you desire.]

Next is the Airtable Automation…

Airtable Automation

GOAL: Create an Airtable Automation with a ‘Run Script’ action.

Steps

Trigger: [select from available Airtable triggers shown below]
Action: Run Script (configure per the example with instructions below)

Airtable Automation Triggers

  • When record matches conditions
  • When record created
  • When record updated (watch all fields or a subset of fields)
  • When record enters view

Example

This example will send a webhook with 5 data points from an Airtable Table that has these fields:

  • Airtable Record ID (NOTE: This is a system generated ID by Airtable for every record)
  • First Name
  • Last Name
  • Email
  • Phone

Script Setup

Input Variables: Define the Input Variables with a Name and Value.

Map Input Variable values to Airtable Table Field values, similar to how you do in a Zap.

Or set Input Variable Values as static values.

Code Configuration

When editing the Airtable Automation Script, copy and paste the code below into the Code section, and modify as needed.

What the code below does is concatenate the webhook url with query string parameters (after the ?) and sends the data as a GET request to Zapier to trigger the Zap.

Suggested to include the Airtable Record ID so you can trace back to the Airtable Record in case you need to troubleshoot.

let url = "[ZapWebhook]"; // Replace the [ZapWebhook] with the webhook provided from the Zap Trigger step.

let config = input.config(); // This allows the Input Variables to be used in the code. 

await fetch(url + "?RecordID=" + config.RecordID + "&FirstName=" + config.FirstName + "&LastName=" + config.LastName + "&Phone=" + config.Phone + "&Email=" + config.Email); // Concatenates the webhook URL with query string parameters and Input Variable values.

Lastly, finish Zap action steps.

Testing

Always make sure to TEST, TEST, TEST.

  • Test the Airtable Automation manually.
  • Test the Zap steps manually.
  • Test end-to-end once live to verify the automations are triggering and processing as expected.

Best Practice: When in doubt, test it out.

Troubleshooting

REMINDER: Remember to turn the Airtable Automation ON and to turn the Zap ON.

  • Check the Zapier Task History and Details here: https://zapier.com/app/history/
  • Check the Airtable Automation Runs log (TIP: Found within each Airtable Automation next to the Steps tab)

Automagical

⚡TADA! … Real-time results bring instant gratification.

Best of luck automating away the agony of your workflows.

Please leave a comment if you have questions or feedback, thanks.

Resources

Zapier Webhooks: https://zapier.com/blog/what-are-webhooks/

Airtable Automation - Run Script Action: https://support.airtable.com/hc/en-us/articles/360051792333-Run-a-script-Action-

P.S. For those interested, here is the Airtable API documentation: https://airtable.com/api

 

Credit: https://community.airtable.com/t/a-little-help-with-a-script-to-trigger-a-webhook/32615

 

20 replies

Userlevel 7
Badge +10

Great run-through @Troy Tessalone! Thanks for posting.

Userlevel 7
Badge +8

+1 to Andrew’s comment! Thanks for sharing, Troy!! Great examples here, @nicksimard

Userlevel 1
Badge

I copied and pasted this script @Troy Tessalone  (and thank you for your guidance!), but Zapier is returning “Undefined” in all 5 fields that I’ve attempted to pull over.

 

Any thoughts?

Jonathan

Userlevel 7
Badge +14

@JoFo 

Please post screenshots of how your Airtable Automation Script is configured and how your Zap steps are configured.

TIP: Make sure you are triggering an Airtable record that has those data points defined.

Userlevel 1
Badge

I’m probably sharing more info that I need to, so I may delete afterwards, but here are some screen shots.  @Troy Tessalone 
 

 

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting. 

Userlevel 7
Badge +14

@JoFo 

Looks like perhaps the Zap action step that is supposed to map the data points from the webhook trigger step to the action step aren’t mapped correctly.

Can you provide a screenshot of how that Zap step is configured?

Did you turn ON the Airtable Automation and test to trigger the Zap webhook, then pull thru that sample data on the Zap trigger?

Article: https://zapier.com/help/create/basics/change-the-test-data-in-your-zap-trigger

 

Userlevel 1
Badge

@Troy Tessalone Here you go.  Is this helpful?  I started over on the Zap from scratch to make sure my fields were correct.

 



 

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting. 

Userlevel 7
Badge +14

@JoFo 

In Airtable, did you define and map variables for those 5 fields?

 

Userlevel 1
Badge

@Troy Tessalone This is where I start to feel dumb, haha.  I’m brand new to Airtable… like within the last week.  Where do I go to input these?  Is it in Automation?  

 

Wait...I found where to do it.  I do feel dumb.  Please hold.

Userlevel 1
Badge

@Troy Tessalone 

You were correct. I needed to define the variables.  I defined them and Zapier pulled the info right over.

Now I have a new problem.

 

When I test the Zap, my text messaging app sends me a text with the info I need.  However, when I turn on the Zap and try a new entry, nothing happens.  The automation and the Zap are both on.

 

Thanks for all your help on this!

Userlevel 1

Hi all and thank you @Troy Tessalone for the really helpfull post 🙌

I followed each step and everything works well 😎I am using it to autocomplete a template in Google Docs.

 

I just have one issue  : the rich text formatting doesn’t work. It returns a string with no multiple lines allowed.

 

Any idea to send my query to the zapier webhook while keeping rich formating field? 🧐

 

Thank you ! 🙏

Userlevel 7
Badge +14

Hi @Joffrey CZB 

Can you outline a more detailed specific example to get a better sense of what you are trying to accomplish with the data from Airtable and the output into the GDoc template?

Userlevel 1

@Troy Tessalone Thank you for your quick reply

 

Here is my Airtable form:

The field named “Tâches détaillés” is formatted as a Long text field with rich text formatting enabled.

 

Here is my script in Airtable:

 

And here is how it appears (red frame) on my Google Docs template after the form is submitted and the zapier actions run:

 

The result I am looking for would be this one (red frame):

 

On zapier, when I use the traditional trigger “New Airtable record” and then the Google Docs action to replace fields in my template, it automatically keeps the “Tâches détaillés” text format (with multiple lines) as shown on my last screenshot.

But when I use your method to generate it instantly, it appears as shown on my third screenshot, without keeping the rich text formatting.

 

Any idea how to keep it formatted with multiple lines?

Hope I am clear enough!

Thank you so much!

Userlevel 7
Badge +14

@Joffrey CZB

In your Zap as Step 2 add an Airtable Find Record step to get that value w/o losing the Rich Text Formatting for the Long Text field.

The example outlined in this article uses a simple GET request which is why the formatting get removed.
The Airtable Automation Run Script action would have to be updated to use a POST method.

Userlevel 1

@Troy Tessalone 

It works perfectly, thank you so much for the tips!

Userlevel 1

This was exactly the help I needed - it works perfectly, thank you!

Userlevel 1

I already have a bunch of zaps set up to trigger from new records. Is it possible to create one new automation zap that triggers each of those zaps, without me needing to change the trigger of each of those zaps?

Userlevel 7
Badge +14

Hi @daverad 

It would be best to start a new topic for your question and make sure to include screenshots with how your existing Zaps are configured.

Userlevel 1

Thanks Troy, great suggestion will do and thanks for the quick response. As I learn more about webhooks / scripting. A quick question: Is there a simple way to to send all the columns from an updated record through to zapier without typing out each one or adding each one as inputs?

Userlevel 1

@Troy Tessalone  actually had a thought, that i could use the webhook to trigger the action, then add a step in my sap to search by record id to pull in all the other fields. in your experience would that work?

 

for some reason I didn’t see the option to Search airtable by record ID, so i created this new post: 

 

Any tips or suggestions welcome!

Reply