How to filter webhook request with conditional header value

:bullseye: What is your goal?

I have a scenario that starts with make.com webhook and i send a custom header in the request “x-webhook-secret”

how do i set a conditional so we make sure the value of this header “x-webhook-secret” is equal to a vlue before moving to the next step module in the scenario

I have searched and searched and have tried different things and it just wont work. i am highly disappointed in make.com for the UX of the webhook module. the first thing we want is to secure and say if some header is equal to a value and it should not be a pain to setup that requires signing up for a forum to get help

:thinking: What is the problem & what have you tried?

i have tried these and none of them work

{{ first(map(1.headers; value; name; x-webhook-secret)) }} from HTTP Header filters - #2 by samliew

which doesnt work because it changes the “-” to subtract

and {{1.__IMTHEADERS__[“x-webhook-secret”].value}} which also does not work as seen in screenshots attached

I have tried many other things but here to ask the community on what the solution to this is

:clipboard: Error messages or input/output bundles

Please check screenshots of many things i have tried that does not work

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

make-crappy-ux-1.pdf (279 KB)

1 Like

@samliew i tried your solution here HTTP Header filters - #2 by samliew but no longer works

1 Like

Hello @bogdon_incognito, welcome to the Community!

Here’s the easiest approach- if possible, change the auth header’s key to x-make-apikey and you will have native authentication provided by Make.com.

If that’s not possible and you must use x-webhook-secret:

  1. Create webhook
  2. While creating the webhook, toggle on Advanced settings and set Get request headers to Yes
  3. Add filter and configure it using function to get value of x-webhook-secret header:
{{get(map(1.`__IMTHEADERS__`; "value"; "name"; "x-webhook-secret"); 1)}}

You can also use:

{{first(map(1.`__IMTHEADERS__`; "value"; "name"; "x-webhook-secret"))}}

And that’s it.

Of course, I would recommend even basic security, so encode your token into a base64 string and use the toBinary() function to decode it.
A better approach is to use an encoded token stored as variable (available on Pro, Teams, and Enterprise plans) or a database item with the Encryptor app module in the scenario, but that requires extra operations.

Here you can find sample scenario:

Have a nice day,
Michal

2 Likes

you are really good!

it worked, i can not design my app for make.com only so cant chose to change to use x-make-apikey

used the get map and it worked

{{get(map(1.`__IMTHEADERS__`; "value"; "name"; "x-webhook-secret"); 1)}}

you saved me hours trying to figure that out, make.com can do better with their docs

thanks again

2 Likes

You mean this one? Where it also has a video explaining how to use the first(map()) combo?

Welcome to the Make community!

Did you modify it to your scenario though? Using the map and get/first functions is the correct way to extract values from an array of collections. You cannot copy an answer without knowing how to change it to suit your data.

Combining Map & Get (or First) functions to get Values from Arrays

The built-in functions map, get, first (or `last) allows you to access values within an array containing collections.

First, use the map function on an array, which returns another array of filtered values —
map(array; key; [key for filtering]; [csv-values for filtering])

Then, the built-in function get (or first/last) to get a specific, single item from the resulting array —
get(array; path)

You will get something that looks like these —

{{ get(map(array; "value"; "name"; "content-type"); 1) }}
{{ first(map(array; "value"; "name"; "content-type")) }}

Map Function Parameters: Step-by-Step

To easily remember how to use each of the parameters of the map function, think of it this way:

  1. From this array (of collections),
  2. I want to get all the the values for the property/key named _______,
  3. Where another property/key _______
  4. has the exact case-sensitive value _______

Example

1. From this array (of collections) user_column_data

2. I want to get all the the values for the property/key named string_value

3. Where another property/key column_id

4. has the exact case-sensitive value EMAIL

5. Output

e.g.:

{{ first(map((1.IMTHEADERS; "value"; "name"; "x-webhook-secret")) }}

:high_voltage: Make Input Markup: Copy-paste the above into the field, including start/end curly brackets for it to import as intended :warning:

Using Join Function to Transform an Array into a Single Text Variable

You can also combine map with join to join the values into a single text string —
``{{ join(map( … ); delimiter) }}```

e.g.:

{{ join(map(array); ", ") }}

For more information, the documentation for the above functions can be found in the Help Centre and the “Mapping with Arrays” link below. You should also complete the tutorials in the Make Academy, especially Using get() and map() functions.

I’d recommend going through the Make Academy if you haven’t yet!

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Learn Make

How-Tos

@samliew