n8n Webhook
My notes on creating a Webhook in n8n
Hello again!
Today, I want to share my notes about creating webhooks in n8n. After building a chatbot or a workflow, you may want to trigger it through an API. In this post, I will explain how to set up webhooks and share a few useful tips. If you want to learn how to build a chatbot with MCP, please check out my previous post.
Last time, I used MCP nodes and the Brave Search API to find answers from the web based on my query.
As you can see, the trigger node is “When chat message received”. Double-click this node:
Can you guess the next step? 🙂 Make the chat publicly available.
Making it public gives us a link that we can use. But first, we need to activate the workflow from the main page:
Great! Let’s try sending a new question:
Now, let’s open the link! n8n shows a nice, clean web page for the chat. (Of course, you can change the initial welcome message in the n8n UI.)
Webhook
What is a Webhook?
A webhook is a way to send data from one place to another automatically. It is like saying, “Hey, when something happens, please call this link and send the information.”
In n8n, webhooks let you start a workflow from outside. For example, you can send a request to a special link, and your workflow will run.
Instead of clicking “Execute Workflow” manually, the webhook listens and runs the flow when it gets a request. It is very useful if you want to connect n8n with other apps, websites, or your own code.
ChatGPT 🧡
Let’s build it step-by-step so I can show you all the confusing parts and how I solved them. I created a Webhook node and directly connected it to the AI Agent node. It looks like this:
In the webhook configuration, I only changed the HTTP Method to POST.
Because I want to post the user’s query to my AI Agent.
Now, let’s use the URL in Insomnia (it’s an alternative to Postman). First, click the Listen for Test Event button (the orange one on top).
Then, send your request from Insomnia.
You will see a message saying “Workflow was started.
That’s a good sign! 🎊
Now, let’s test the second part — the AI Agent. As you can see below, it gives an error. The reason is: it expects the source to be a Chat Trigger node. But now, we are using a Webhook.
To fix it, change the source setting to “Define below”. Then, select user_query as the source as shown below. (Just drag and drop)
Another error appears! Now it says we need a sessionId. This is because we are using Simple Memory to keep the chat history.
Let’s add sessionId to the body like this:
{ "user_query": "Recommend me a place to stay in NewYork",
"sessionId": "user_123" }Before trying it, don’t forget to save! 📝
- Save the workflow
- Click the Listen to Test Event.
- Send the Request from Insomnia.
- Then test the AI Agent again.
Open the Session node and update it like this:
Now, the AI Agent test is successful! 🎯
But wait — when I send the request from Insomnia, I noticed something:
Problem in node 'AI Agent'
Cannot read properties of undefined (reading 'content')Oops! The response was missing.
Get Pelin Balci’s stories in your inbox
Join Medium for free to get updates from this writer.
The reason is, we didn’t add a Respond to Webhook node. I fixed it by the adding a Respond to Webhook node after the AI Agent. Also, I changed the Webhook settings: Instead of “Respond Immediately”, I selected “Respond using ‘Respond to Webhook’ node”.
Now, the workflow is ready to send and receive requests through Insomnia! 🚀
Common Errors and Quick Fixes
Error: Missing user_query
→ You need to change the Source setting in the AI Agent node to “Define below” and select user_query.
Error: Missing sessionId
→ Add a sessionId field to the request body.
→ Also, make sure to update the Session node to use this sessionId.
Error: Request gets stuck / No response
→ Add a Respond to Webhook node after the AI Agent.
→ In the Webhook node settings, select “Respond using ‘Respond to Webhook’ node” instead of “Immediately”.
Tip:
- Always click Save after making changes! 📝
- Always click Listen for Test Event before sending your test request.
How to Access Your Webhook from Outside Your Local Computer
If you are building and testing on your local machine (like me!), your webhook URL looks something like:
http://localhost:5678/webhook-test/5a4-bc5-885
But this link only works on your own computer. If you want to access your webhook from anywhere (for example, from your phone, or from a server), you can use n8n cloud.
✅ Use n8n Cloud: The easiest way is to create your workflow on n8n Cloud. n8n will give you a public URL automatically. No extra setup is needed!
I’ve tried this step and give me a valid URL that can be used in any application.
️⚠️The rest of the options are coming from ChatGPT. I haven’t tried them.
If you want to keep working on your local machine, you can use a tool to open a tunnel to your localhost. Here are some popular options:
ngrok (most popular)
localtunnel (easy and open-source)
cloudflared (free and secure)
⚠️ Important Warning
When you open your localhost to the internet using a tunnel, your computer becomes publicly reachable. Please be careful!
💥 Do not share your tunnel link with others.
💥 Avoid sending sensitive data through public tunnels.
💥 Close the tunnel when you are done testing.
🌟 If you are working on something important or private, it’s better to use n8n Cloud or set up a server with proper security.🌟
Summary
In this post, we learned how to trigger an n8n workflow using a webhook. We created a simple flow, connected it to an AI Agent, and tested it with Insomnia. We solved common errors like missing fields and missing responses.
Hope this guide helps you to build even more creative automations. 🎯
Happy learning! 😃









