Aug 20, 2021 11:33 AM
Hi,
I’m new to Airtable scripting and am just learning my way around through hit & trial. I don’t have any javascript experience either, but I’ve used python in the past. I’m trying to write an Airtable script that sends data to my Integromat webhook trigger. So far I’ve been gotten the following:
// Webhook URL
let webhook = 'https://hook.integromat.com/integromaturl'; // replace with actual integromat URL
// Table to send data from
let tableName = 'Master Client';
// Fields to bind and send
let fieldsToSend = [
'Client ID',
'Client Name',
'Email',
'Created Time',
'Last Modified'
]
I guess I’m stuck with what to do after this. My intent is to use the Airtable automation such that when a new record is created in this table (Master Client), I want this script to run.
But what do I need to add to my script so that Airtable sends the information in my ‘fieldsToSend’ variable to my ‘webhook’ variable. All I seem to have done in my script is to create and assign variables – it doesn’t really do anything.
Sorry if this is stupid and really basic, I’m literally just figuring this out from scratch.
Any help would be much appreciated.
Thank you.
Solved! Go to Solution.
Aug 26, 2021 05:57 AM
If you are doing this as an automation you need to setup an input variable for the script using the airtable record ID that you want to send as the data - in this example i’ve called it “inputRecord” (this will vary depending on your approach, but it’s usually the record id from step one / the trigger of your automation).
Generate your webhook url in integromat and insert it into line 5 of the following code:
let inputConfig = input.config();
let recordID = inputConfig.inputRecord;
console.log(recordID);
let url="*integromat webhook url goes here*"
console.log(url);
let request= url.concat('?recordID=',recordID)
console.log(request);
await fetch(request);
Hope that helps!
Aug 23, 2021 03:50 PM
Don’t bother with all that - just send over the record Id and use integromat’s get record function to grab the actual data.
Aug 23, 2021 04:23 PM
Okay, but how do I do that? I want a script to trigger sending to a webhook instantly and not use the Integromat scheduled triggers.
So I’ll reduce the variable down to just the record ID, but what else do I need to put in the script to send a POST (I think that’s what it is) request?
Aug 26, 2021 05:57 AM
If you are doing this as an automation you need to setup an input variable for the script using the airtable record ID that you want to send as the data - in this example i’ve called it “inputRecord” (this will vary depending on your approach, but it’s usually the record id from step one / the trigger of your automation).
Generate your webhook url in integromat and insert it into line 5 of the following code:
let inputConfig = input.config();
let recordID = inputConfig.inputRecord;
console.log(recordID);
let url="*integromat webhook url goes here*"
console.log(url);
let request= url.concat('?recordID=',recordID)
console.log(request);
await fetch(request);
Hope that helps!
Aug 27, 2021 06:50 AM
Thanks. I’ll try this out and let you know how it goes. Really appreciate it.
Aug 27, 2021 08:52 AM
Thank you. This worked perfectly.
May 04, 2023 03:32 AM
Hey Joe, what if all you need from the trigger record is the RecordID and one other single line text field? Wouldn’t it be more efficient to send both pieces of data in the webhook vs expending another operation on the Get Record module?
Can you please show us how that second line of data can be written into the AT script?