Is it possible to read a webhook data from a script?

I created an automation with a Webhook trigger.

When calling that webhook, I want to run a script that reads the webhook data (POST) and use them in my script.

I haven’t found how to do something as simple as that so far. I’m starting to believe this isn’t possible.

1 Like

If I understand your objectives clearly, there is a way and I do this a lot in a number of systems. In this screenshot, take a close look at the left pane containing input parameters into the script action. You can see that two elements from the webhook post (the first step in the automation) includes values from the body of the HTTP POST.

1 Like

@Bill.French Thanks, I finally figured as much, but this is rather limited when you want to use objects or dynamically provided structures. I just wanted to manipulate a “data” element with unforeseen structure, not doable.

Also, you leaked your API access key in the above screenshot, not sure if that was intended!

Yeah - I meant to publish without that key. Thx.

Right, we can’t pass the body into the script - that was the basis for my original complaint when this feature was first made available. Someone wasn’t thinking and that someone needs to be spanked.

2 Likes

Two Workarounds

  1. The first workaround for this is possible if you have control over the service making the webhook call. Simply serialize the entire payload into a single data field, and then extract and parse that field on the Airtable side.

  2. The second workaround is to create a proxy service using Autocode. Post the webhook call into your proxy service, serialize the payload into a single added element, and push the augmented payload to its final Airtable webhook endpoint.

Both approaches will require a comprehensive enumeration of payload to handle the anticipated dynamic structure of the data, but that was a given in your scenario at the outset.

I’ve had success with each of these approaches.

Op-Ed

It’s not uncommon for Airtable to paint integration developers into corners like this; there’s a long and storied history of shortcomings like this one. But, this one in particular is a doozy.

They really need to have some senior integration experts on their team who will regularly question the data interchange design, in this case, the inability to foresee that someone might actually want to treat body as a field containing a collection of fields which themselves may also contain additional fields.

In the final analysis,

Is it possible to read a webhook data from a script?

Yes, absolutely. But it is not possible to read [arbitrary] dynamic data, the likes of which tend to occur in more than 50% of the cases.

1 Like

Honnestly, I’ve used the Next.js framework with Vercel cloud hoster and I have my own “webhook” script that does exactly what I want, without the Airtable crazy limitations. Took me about 3h to get straight. (oh, and it’s secure, too, unlike those **** AT webhooks which don’t even embed any kind of authentication system)

It won’t count towards my 25 automations quota, and it won’t count toward my 50k monthly automations runs. And the code is properly versioned.

There are a lot of wins by not using Airtable.

1 Like

It’s my first week with AT scripting and I think it wasn’t intended to be used by actual developers…

Good point. However, sometimes actual developers are forced into helping their clients and organizations adapt to new platforms. Whether this “no-code” platform was ever intended to have a scripting element is uncertain, but the irony of all the code required to make it work well does not escape me.

I figured you did, but by comments nudged along by your comments, were intended for the vast audience of users and low-code builders who want to better understand the issues and need alternative approaches.

1 Like