Webhooks with make and n8n

Webhook essentials for make and n8n - What you should know when using webhooks in automations

In my software engineering career of 8 years, I have worked a lot with APIs, and occasionally webhooks.

When I started automations, webhooks became essential. It is a way of instantly triggering a workflow.

When you send a request to a webhook, it's just like an API call. So what's the difference?

In an API call, we request data from a service, eg: Request weather data.

In a webhook, the service gives us a URL to be called whenever an event occurs eg: Let me know when you receive an email.

We send a request to the given URL with relevant data.

Webhooks in Make.com

There are 2 modules to create a webhook, Custom webhook and Custom mailhook.

Custom webhook gives you a unique URL to be called when you want the scenario to be triggered.

Custom mailhook gives you a unique email address which you can use to set up mail forwarding, so that you can trigger a workflow instantly when an email is received.

The Webhook response module lets you send data back in the response, this is usually added at the end of a scenario.

Webhooks in n8n

There are two nodes.

Webhook node gives you a URL to be called when you want the workflow to be triggered. Actually there are 2 URLs, test URL and production URL.

You can use the test URL while building the workflow.

When you finalize the workflow, you can switch to the production URL.

Webhooks in selfhosted n8n

Most users self host n8n. Using webhooks in self hosted n8n needs a little bit more work. Because it gives a local URL which cannot be called from outside the host.

For example, I have n8n running in my computer. The webhook URL is http://localhost:5678/webhook-test/d4a7a558-ca33-4fe1-a358-9d0b185da077

This is not accessible from outside my computer. If I want to call this URL from another service, I have to map it to a URL that can be accessed from the internet.

There are 2 options to achieve this.

Option 1: ngrok

  • Install ngrok and run: ngrok http 5678.

  • Replace the localhost URL with the ngrok-generated URL.

eg: ngrok will provide a public URL like https://abcd1234.ngrok.io.

Replace http://localhost:5678 in your Webhook URL with the ngrok URL (e.g., https://abcd1234.ngrok.io/webhook/my-webhook).

Option 2: Cloudflare Tunnel

  • Set up and configure a Cloudflare Tunnel.

  • Use the Cloudflare URL for your webhook.

If you have self hosted on a cloud server, you should be able to set the webhook URL as an environment variable.

Security

The webhook URL can be called by anyone. If it got exposed, someone can misuse it.

To protect your scenario, Make.com allows you to restrict calls by IP. It is not enabled by default, you will have to set it by editing the webhook.

In n8n you can use different authentication methods.

That’s all for today.

Hope you have a wonderful week!!!