Automations: Passing input variable with webhook?

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…

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.

@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

4 Likes

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

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.