Skip to main content

Webhook POST push - hopefully useful for somebody!


  • New Participant
  • 3 replies

I saw a few posts regarding posting a webhook, but didn’t see this type outlined below. I used it to send a prefilled form URL from AirTable through to Integrately (or Zapier etc). I’m not a particularly good coder so any feedback would be welcome!

let inputConfig = input.config();

//URL is defined here
let url = "URL OF THE WEBHOOK GOES IN THESE QUOTES";

//This is what the webhook is sending. You can customise the name of each parameter in the brackets. 
let payload = {
"Variable1": inputConfig.Variable1,
"Variable2": inputConfig.Variable2,
"Variable3": inputConfig.Variable3,
"Variable4": inputConfig.Variable4,
}

let postOptions = {
method: "post",
headers: {
'Accept' : 'application/json',
},

body: JSON.stringify(payload)
}

//This is the code to post the webook with the parameters
await fetch(url, postOptions);

4 replies

Justin_Barrett
Forum|alt.badge.img+5

Thanks for sharing! While the layout of the script is pretty good overall, this part is unnecessary:

Those assigned variables aren’t used elsewhere, and you directly retrieve the inputConfig variables again later in the script, so those lines aren’t contributing anything to the end result.


  • Author
  • New Participant
  • 3 replies
  • November 4, 2021
Justin_Barrett wrote:

Thanks for sharing! While the layout of the script is pretty good overall, this part is unnecessary:

Those assigned variables aren’t used elsewhere, and you directly retrieve the inputConfig variables again later in the script, so those lines aren’t contributing anything to the end result.


Good point! I’ll update


  • New Participant
  • 1 reply
  • February 3, 2022

Not sure if its the best script, but this works well too:

let url = "<webhook url>";
let config = input.config();
await fetch(url + "?RecordID=" + config.RecordID + "&Platform=" + config.Platform + "&Channel=" + config.Channel + "&Date=" + config.Date + "&Topic=" + config.Topic, {method: 'POST'});


This is super helpful - thanks for posting!


Reply