Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: Automations: Passing input variable with webhook?

Solved
Jump to Solution
1361 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Liz_Pulo
4 - Data Explorer
4 - Data Explorer

Using the new automations feature, I am trying to trigger an Integromat webhook when a new record enters a view.

However even though I have configured an input variable, and it is processing just fine, it won’t parse into the webhook URL.

I’ve attached some screenshots which hopefully explain what I mean.

The code I’m using is:

let data = input.config();

let response = await fetch('WEBHOOKURL?id=${data.ID}');

console.log(await response.text());

The test output shows the variable is picked up:
image

However the webhook receives only the code:
image

Would love some help - I’m sure I’m missing something very simple here…

1 Solution

Accepted Solutions
Jeremy_Oglesby
14 - Jupiter
14 - Jupiter

@Liz_Pulo and @Bill.French
Unless my eyes deceive me, I think the problem is pretty simple…

You have single-quotes surrounding your string, into which you are trying to interpolate a variable. In JavaScript, you have to surround your string in back-ticks in order for it to process interpolated variables.

So you need to replace:

let response = await fetch('WEBHOOKURL?id=${data.ID}');

with:

let response = await fetch(`WEBHOOKURL?id=${data.ID}`);

(notice how even this forum’s code-block text-formatting convention recognized a difference between how the two should be interpreted)

https://www.tutorialspoint.com/how-to-do-string-interpolation-in-javascript

See Solution in Thread

3 Replies 3

Hi Liz, and welcome to the community!

I would test more precisely the actual URL being used to call the webhook. In fact, consider creating the URL as a variable and then inspect that variable for proper formatting with the parameter embedded. I have a hunch it is not what you think it is, or … the webhook itself is not parsing the value as you expect it should.

Jeremy_Oglesby
14 - Jupiter
14 - Jupiter

@Liz_Pulo and @Bill.French
Unless my eyes deceive me, I think the problem is pretty simple…

You have single-quotes surrounding your string, into which you are trying to interpolate a variable. In JavaScript, you have to surround your string in back-ticks in order for it to process interpolated variables.

So you need to replace:

let response = await fetch('WEBHOOKURL?id=${data.ID}');

with:

let response = await fetch(`WEBHOOKURL?id=${data.ID}`);

(notice how even this forum’s code-block text-formatting convention recognized a difference between how the two should be interpreted)

https://www.tutorialspoint.com/how-to-do-string-interpolation-in-javascript

Liz_Pulo
4 - Data Explorer
4 - Data Explorer

That is exactly it… thank you Jeremy!!! It’s now working :slightly_smiling_face: