Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Feb 28, 2020 01:25 AM
Hey, is it possible to create some Action Buttons to push webhooks with json data with the scripting block?
Jan 16, 2021 11:21 AM
Oooh, thank you!! That’s a really great idea! :slightly_smiling_face: I haven’t jumped on the ball yet of creating my “Airtable Hot Tips” video series yet (which was originally YOUR idea for me!), but this would be a great one to kickstart the series! :slightly_smiling_face:
Jan 16, 2021 11:24 AM
Especially if it included a little script snippet to demonstrate how to call an Integromat webhook from a button or an action.
Jan 18, 2021 12:02 AM
Hi Bill,
thanks for your response.
It seems to be a cache issue. After i cleared the cache of my browser the button works as expected. So the problem is solved.
Have a great start in the week.
Kai
Jan 20, 2021 02:20 AM
Hi Scott,
As Bill said it’s possible, and you can pass the record ID like you would for the Button/Webhook trigger :
let url = "https://hook.integromat.com/xxxxxxxxxxxxxxxxxxxxxxx?recordID=";
let inputConfig = input.config();
await fetch(url + inputConfig["recordID"]);
This allows to trigger Integromat scenarios immediately when specific conditions are met in Airtable, without having to set a periodic schedule in Integromat (thus reducing the operations count & latency).
Jan 20, 2021 07:28 AM
Thanks for the JavaScript code!
Jan 20, 2021 11:28 PM
This is awesome. It seems like every time I’m trying to solve a problem, the solution has just recently been posted in the forum. Thanks for sharing the code and knowledge.
Jan 21, 2021 06:08 AM
Yep - this is a great example.
Caution
You may also want to test to see if the webhook fired and if not, determine the cause of the failure if the process is a mission-critical process.
Jan 21, 2021 03:00 PM
My current use case isn’t mission critical, but I’m interested in using this for automating other processes in the future in the future.
@Bill.French do you know of a simple way to test to see whether the webhook has fired or not? Would you suggest adding something to the javascript?
I can think of several ways to do this that require way more steps (like adding a step to the initial automation that checks a box, then adding an uncheck box step to the webhook function), but wonder if there’s an easier way in the script itself to check to make sure that the webhook has fired properly.
Thanks!
Jan 21, 2021 03:26 PM
It’s not really a question of firing; it’s determining what happened after the fire. If it failed or succeeded typically depends on what the response is from the hook. They vary in what (if anything) is returned when the request is made, but in most cases they conform to API standards issuing an HTTP response code.
Oct 12, 2021 01:37 AM
I just thought I might add what I have done to this as I stole a few things and mashed them together…
I have an automation, when a particular sales status is reached, I want to send a JSON payload with two parameters. Now I know I could send one parameter, but this webhook is actually set off not just by Airtable and there are times that the extra parameters are not in Airtable, e.g. they are sent from the automation.
let url = "<webhookURL obv deleted here>";
let inputConfig = input.config();
let payload = {
"record": inputConfig["recordID"],
"emailType": inputConfig["salesStatus"],
}
let postOptions = {
method: "post",
headers: {
'Accept' : 'application/json',
},
body: JSON.stringify(payload)
}
await fetch(url, postOptions);
So I am passing it, in this instance, the recordID and the salesStatus from my record. You could really continue building out the JSON payload with as much information as you want, although of course you could also grab this by sending just the ID and then grabbing the rest in Integromat…
So people above seem to be getting back results, unsure what they are doing with that exactly though??
e.g. what is this doing?
const postResults = await fetch(url, postOptions);
const jsonPost = postResults.json();
let id = (jsonPost.field + " = " + jsonPost.value);