n8n Respond to Webhook 教學:讓表單收到確認回覆,而非「Workflow was started」
n8n Respond to Webhook: Your Form Gets "Workflow was started" Instead of a Reply. Change One Setting, Add One Node
這篇 n8n 教學示範如何設定 Webhook、Edit Fields(Set)和 Respond to Webhook,讓網站表單收到根據提交資料生成的確認回覆,而非預設的「Workflow was started」。
A website form that shows nothing after Send gets sent twice. Or the visitor calls the office to ask if it went through.
If that form posts to an n8n webhook, the fix is two settings and one node. This walkthrough builds it for a made-up architecture studio: a homeowner sends a consultation request, n8n builds a confirmation with their name in it, and sends it back to the page in the same second.
The workflow is three nodes and needs no credentials, so you can rebuild it in your own n8n in a few minutes.
Webhook → Edit Fields (Set) → Respond to Webhook
Why your webhook answers "Workflow was started"
The Webhook node has a Respond setting with four choices:
| Respond | What the caller gets |
|---|---|
| Immediately (default) | An instant "Workflow was started", before any of your steps run |
| When Last Node Finishes | The output of the last node that ran |
| Using 'Respond to Webhook' Node | Whatever a Respond to Webhook node sends, when it sends it |
| Streaming | A streamed response |
The default is Immediately. That's fine for fire-and-forget events, but it means the caller hears back before your workflow has done anything useful. A form can't show a confirmation built from data that doesn't exist yet.
The other half of the trap: a Respond to Webhook node does nothing by itself. The Webhook node has to be told to wait for it. n8n shows a reminder under the Respond field once you pick the right option, and the Respond to Webhook node carries the matching note at the top of its panel. They only work as a pair.
Step 1: Catch the request
- Add first step → On webhook call.
- HTTP Method: change GET to POST. Website forms send their answers with POST.
-
Path: replace the random string with something readable:
consultation-request.
Step 2: Make the webhook wait
- Open Respond (it says Immediately).
- Choose Using 'Respond to Webhook' Node.
- Click Listen for test event and send a test request to the Test URL.
Any HTTP client works for the test. With curl, using your own Test URL:
curl -X POST "https://YOUR-N8N/webhook-test/consultation-request" \
-H "Content-Type: application/json" \
-d '{"name":"Jordan Ellis","email":"jordan.ellis@example.com","project_type":"kitchen extension","budget":80000}'
One item arrives. The form answers sit under body:
{
"body": {
"name": "Jordan Ellis",
"email": "jordan.ellis@example.com",
"project_type": "kitchen extension",
"budget": 80000
}
}
Note the body level. It's why the expression in the next step is $json.body.name and not $json.name.
Step 3: Build the reply with Edit Fields
Add Edit Fields (Set) after the Webhook and create two fields:
| Name | Value |
|---|---|
message |
{{ $json.body.name }}, we got your request. We will call you within one business day. |
status |
received |
You can type the expression, or drag name from the INPUT panel onto the value box and n8n writes it for you. Then type the rest of the sentence after it.
Click Execute step. The output has only your two fields:
{
"message": "Jordan Ellis, we got your request. We will call you within one business day.",
"status": "received"
}
This is the quiet benefit of Edit Fields here: the email and the budget stay inside n8n. Only the fields you set are sent back to the browser. If you reply with the raw webhook item instead, you echo the whole request, headers included.
The status field is for the website: its code can check for received and show a green tick.
Step 4: Send it back
- Add Respond to Webhook after Edit Fields.
- Respond With: leave it on First Incoming Item. That's the item Edit Fields just built.
-
Add option → Response Code →
200. - Execute step.
The other Respond With choices are worth knowing:
- All Incoming Items sends a list (useful when you return several rows).
- JSON lets you write the reply by hand, with expressions in it.
- Text sends plain text or HTML.
- Redirect sends the visitor to another page, such as a thank-you page.
- No Data sends only the response code.
And the response code is how the caller knows what happened: 200 for OK, 201 when something was created, 400 when the request was wrong. A form's script can branch on it.
What the front end sees
On the website side, the form's submit handler just reads the JSON. A minimal version:
const res = await fetch("https://YOUR-N8N/webhook/consultation-request", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData),
});
const data = await res.json();
if (res.ok && data.status === "received") {
showConfirmation(data.message);
}
Notice that URL has /webhook/, not /webhook-test/. That's the last step.
Step 5: Test URL vs Production URL
Every Webhook node has two addresses:
| Path contains | Works when | |
|---|---|---|
| Test URL | /webhook-test/ |
Once, each time you click Listen for test event. Data shows in the editor. |
| Production URL | /webhook/ |
All the time, but only after the workflow is published. |
Pasting the Test URL into a live website is the most common webhook mistake. It works while you're watching the editor and stops the moment you close it. Use the Production URL in the form, then Publish.
Where to put the Respond node
Put Respond to Webhook at the point where the answer is ready, not necessarily at the end. Steps after it still run.
That matters when the workflow also does slow things: writing to a sheet, sending an email to the office, calling an AI model. Reply to the visitor first, then do the slow work after the Respond node. The form gets its confirmation in a second instead of waiting on Gmail.
If only some requests should get a reply, put a Filter or an If node before the response.
Quick checklist
- [ ] Webhook HTTP Method is POST
- [ ] Webhook Respond is Using 'Respond to Webhook' Node
- [ ] Expressions read from
$json.body.<field> - [ ] Edit Fields returns only what the browser should see
- [ ] Respond to Webhook sends First Incoming Item with a Response Code
- [ ] The website uses the Production URL (
/webhook/) and the workflow is published - [ ] Slow steps come after the Respond node
Practice it
I built this as a free step-by-step lesson where you do every click in a practice copy of the n8n editor (31 steps, about 8 minutes, no account needed). It also has the workflow JSON to import: n8n: Reply to a Web Form Instantly with Respond to Webhook.
來源:DEV Community · dev.to