
Build Log: An AI Lead Qualifier in n8n with a Webhook and OpenAI
Build Log: An AI Lead Qualifier in n8n with a Webhook and OpenAI
What this build is
The build is a seven-node chain in n8n: an inbound lead hits a webhook, gets normalized, is scored High, Medium, or Low by an OpenAI model called through the OpenAI node’s V2 surface, parsed and validated, routed to a sink, and answered with structured JSON — and the Webhook node documentation covers the ingress and response mechanics end to end.
The framing matters as much as the flow. This is a reference build assembled from official documentation and community reports, not a war story: the configuration below follows what the docs specify, the cost arithmetic uses only published figures, and the gaps — chiefly OpenAI per-token pricing — are called out rather than papered over.
The hook that makes this particular shape worth writing up: in n8n, a seven-node chain costs one execution, not seven. n8n’s pricing page defines an execution as one run of the entire workflow regardless of the number of steps, which changes the cost math materially once a workflow grows past a couple of nodes.
How this guide was built
This guide is assembled from official documentation and community reports — we did not run this build ourselves. The sourcing base is the n8n documentation node pages, n8n’s pricing page, Zapier’s pricing page, and Make’s pricing FAQ, plus one community thread cited only as a community example.
The rule the reader can hold this post to: every number traces to one of those pages. Figures that were not verifiable during research — OpenAI per-token rates, Make’s paid-plan prices — are deliberately absent rather than approximated. Where a claim is structural or conventional rather than documented, it is labeled as a general pattern so you know how much weight it can bear.
The architecture at a glance
The seven stages are Webhook (POST) → Set/Normalize → OpenAI (Responses API) → Parse & Validate → IF/Switch → a sink such as a sheet append → Respond to Webhook, and this shape matches a community example thread on n8n’s forum describing a webhook-to-JSON lead qualification flow.
Two design decisions are worth stating before the node detail.
First, the community thread is cited as shape, not as capability proof — it shows that people assemble workflows in this configuration, while every functional claim in this post comes from official docs.
Second, the scoring call uses the OpenAI node directly rather than the AI Agent node. The AI Agent node documentation states that you must connect at least one tool sub-node to an AI Agent node. A single classify-and-route job gains nothing from tools, so the plain OpenAI node is the lighter and more appropriate choice here.
Node-by-node build sequence
Each of the seven nodes below is paired with the config it needs and the docs page that justifies it, starting with the Webhook node documentation and the OpenAI node documentation, which together cover most of the build’s real decisions.
| # | Node | Config essentials | Docs justification |
|---|---|---|---|
| 1 | Webhook | POST method; Header auth; respond mode “Using Respond to Webhook node”; 16MB default payload cap; test vs production URL | Webhook node docs |
| 2 | Set (Edit Fields) | Map inbound fields to a canonical lead object; trim; pre-build the prompt payload | General n8n practice |
| 3 | OpenAI (V2) | n8n 1.117.0+; “Generate a Model Response”; credential or Gateway credits; request High/Medium/Low plus a reason | OpenAI node + credentials docs |
| 4 | Parse & Validate | Extract the score; enforce the three literal values; fallback branch | General pattern |
| 5 | IF / Switch | Three-way branch on equality against the literal scores | General pattern |
| 6 | Sink | High → sheet append or CRM; Medium/Low → log or second sheet | Qualitative |
| 7 | Respond to Webhook | Return {score, reason} JSON with explicit status |
General n8n practice |
1. Webhook: the ingress point
The Webhook node is the build’s only ingress. The docs specify methods DELETE, GET, HEAD, PATCH, POST, and PUT, so this node is set to POST, with Header auth chosen from the available authentication options (Basic, Header, JWT, n8n User Auth, or none). Decide the respond mode at configuration time: select “Using ‘Respond to Webhook’ node” rather than “When Last Node Finishes,” because explicit control of the response body and status is the point of a JSON API. Note also the default maximum payload of 16MB, and read the two-URL model carefully: the test URL works only while “Listen for Test Event” is selected and displays data in the editor, whereas the production URL registers on publish and logs runs to the Executions tab.
2. Set: normalize into a canonical lead object
The Set node (Edit Fields) converts whatever the sender posts into one predictable shape. Map inbound keys onto a canonical lead object — name, email, company, message, source — trimming whitespace and discarding anything unused. The second job is the important one: build the prompt payload as a single expression in one field, so the OpenAI node references exactly one expression instead of re-assembling context inline. This is general n8n Set-node practice rather than a documented requirement, but it keeps the prompt contract auditable in one place and makes the downstream parse step far easier to reason about.
3. OpenAI node V2: the scoring call
This is where the qualifier earns its name. Per the OpenAI node documentation, OpenAI node V2 is available from n8n 1.117.0 and supports the OpenAI Responses API; it removes support for the Assistants API, which OpenAI has announced plans to retire. Use the text operation “Generate a Model Response.” Credentials are configured per the OpenAI credentials documentation, and on n8n Cloud the node can use Gateway credits instead of your own OpenAI key. In the prompt, state the output contract explicitly: return exactly one of High, Medium, or Low, plus a short reason. Requesting a constrained, structured score keeps the next node simple.
4. Parse and validate
Extract the score field from the model’s output and enforce that it is exactly one of the three literal values. Anything else — a malformed block, an off-menu label, an apology — is routed to an error branch rather than allowed through. This stage is a general integration pattern rather than a documented n8n node, and it appears as an explicit stage in the community example workflow. The design principle is that the workflow, not the model, owns the schema: downstream branches should only ever see values they were written to expect.
5. IF / Switch: three-way routing
A Switch node (or three chained IF nodes) branches on the validated score using equality checks against the literals High, Medium, and Low. Because the previous node already enforced the vocabulary, these comparisons cannot silently fall through to an unintended path. Keep the conditions dumb on purpose — no fuzzy matching, no contains-logic — so that a routing change later is a config edit rather than a rewrite.
6. Sink: where qualified leads land
High-scoring leads append to a sheet or push into a CRM; Medium and Low leads are logged, or written to a second sheet for nurture. The sink is deliberately generic here because every connected service brings its own credential and its own rate or quota considerations, and those are outside the scope of what was verified for this post. The design point that carries over regardless of sink: each branch is a separate node, so one failing connector does not block the other two paths.
7. Respond to Webhook: closing the loop
The final node returns the structured result to the caller, shaped like {score, reason}, matching the “Return Structured JSON” stage in the community example. Choosing “Using ‘Respond to Webhook’ node” over “When Last Node Finishes” — an option documented in the Webhook node’s respond settings — gives explicit control over the response body and lets you return an error payload deliberately rather than by accident.
Why not the AI Agent node? The docs state you must connect at least one tool sub-node to an AI Agent node, and a deterministic scoring call does not need tools. The plain OpenAI node is the lighter, correct choice for a single classify-and-route job.
Version caveat. On n8n versions below 1.117.0, the OpenAI node predates V2 and the Responses API. Separately, the AI Agent node documentation notes that AI Agent node v1 will be removed from n8n 3.0, and that the agent-type setting is deprecated from 1.82.0. Node surfaces churn; pin versions in anything load-bearing.
What one run costs
Assumptions (stated so you can re-run with your own numbers): 500 inbound leads per month; the n8n workflow is the 7-node chain above; the comparison Zapier Zap has a webhook trigger plus 5 billable action steps (per Zapier’s pricing page, triggers and built-in Filter, Formatter, Paths and Delay steps do not count as tasks; external app actions do); the comparison Make scenario has 6 operating modules plus 1 router (router = 0 credits).
n8n. The Starter plan is 20 EUR/month billed annually with 2.5K workflow executions. Because one execution is one run of the entire workflow regardless of step count, the 7-node chain is 1 execution per lead: 500 leads consume 500 of 2,500 executions, or 20% of the allowance. Amortized, that is 20 ÷ 2,500 = 0.008 EUR per execution. The Pro plan (50 EUR/month annual, 10K executions) has headroom to spare at this volume. Community Edition is free and self-hosted, with source on GitHub; n8n’s pricing page lists it with no execution tier. The self-hosted Business plan is different: it is licensed with a 40K-execution quota.
Zapier. 500 runs × 5 billable steps = 2,500 tasks per month. Zapier’s free plan allows 100 tasks per month, which is insufficient; the Professional plan starts at $19.99/month and unlocks multi-step Zaps. Task allowances by tier, and the fact that AI model tier, code runtime, and connector type each affect how many tasks an action uses, are covered on Zapier’s rates page — read it rather than trusting any single figure.
Make. 500 runs × 6 credits = 3,000 credits per month, against 1,000 credits per month on Make’s free plan, so free does not fit. Most actions consume 1 credit, while router modules and error-handler modules consume none. Paid-plan prices were not verified for this post, so consult Make’s pricing page directly.
OpenAI. Per-token cost is intentionally omitted. Per-token pricing changes and was not verified for this post — read current rates from OpenAI’s live pricing page before you model your own budget.
| Platform | Metering unit | Free tier | Needs for 500 leads/month | Fits free tier? |
|---|---|---|---|---|
| n8n | Execution = one full workflow run, any step count | Community Edition self-hosted (free); Starter 20 EUR/mo annual with 2.5K executions | 500 executions (20% of Starter allowance) | Yes (CE) / yes (Starter) |
| Zapier | Task; external action steps consume tasks (triggers and built-in Filter/Formatter/Paths/Delay do not) | 100 tasks/month | 2,500 tasks (500 × 5 billable steps) | No |
| Make | Credit; most actions = 1, routers/error handlers = 0 | 1,000 credits/month | 3,000 credits (500 × 6 modules) | No |
The structural takeaway: n8n’s step-agnostic execution metering is the cost advantage once workflows exceed a couple of nodes.
Where this build breaks: three failure modes
[Documented] Test vs production URL confusion. The test URL works only while “Listen for Test Event” is selected and shows data in the editor; the production URL registers when the workflow is published, displays nothing in the editor, and logs runs to the Executions tab. Symptom: no data appears in the editor after going live. Fix: publish, then hit the production URL and check Executions — per the Webhook node documentation.
[Documented] Payload over the 16MB cap. The Webhook node’s default maximum payload is 16MB, and self-hosters can raise it with N8N_PAYLOAD_SIZE_MAX (Webhook node page). Mitigation, a general pattern: send a reference — a URL or ID — rather than the blob itself.
[General pattern] The model returns malformed or off-menu JSON. This is not a documented n8n behavior; it is a general LLM-integration pattern. Mitigations: state an explicit output contract in the prompt, keep a dedicated parse-and-validate step, and route failures to an error branch that returns an error payload instead of a score, rather than crashing the run.
Avoiding lock-in: self-hosting and exports
n8n’s Community Edition is free and self-hosted, with source published on GitHub. Plan limits — execution allowances, concurrency caps, maximum execution durations — are listed per plan on n8n’s pricing page. Community Edition appears there with no execution tier; the self-hosted Business plan keeps a 40K-execution quota.
Export portability was not verified for this post; check n8n’s export documentation before you rely on it. The N8N_PAYLOAD_SIZE_MAX knob already illustrates the underlying point: self-hosters hold configuration levers Cloud users do not. And the credential layer — your OpenAI key, your sheet or CRM — stays yours in either deployment mode.
FAQ
Does every node cost an execution in n8n?
No. n8n defines an execution as one run of the entire workflow regardless of the number of steps, per the definition on n8n’s pricing page. A seven-node lead qualifier therefore consumes one execution per lead, not seven, which is the structural reason the arithmetic above works out the way it does.
Do I need the AI Agent node for this build?
No. The AI Agent node documentation states you must connect at least one tool sub-node to an AI Agent node, and a deterministic classify-and-route call gains nothing from tools. The plain OpenAI node handles a single structured scoring request with less machinery.
Can I run this workflow for free?
Partly. n8n’s Community Edition is free and self-hosted, though infrastructure and OpenAI usage still cost money. On competitor free tiers the volume does not fit: Zapier’s free plan allows 100 tasks per month and Make’s free plan allows 1,000 credits per month.
The Bottom Line
Webhook mechanics and execution metering are documented on n8n’s pricing page and in the Webhook node documentation, while per-token cost remains an open item you must check at source.
Recommend it for teams already inside n8n, or weighing it against per-step billing on Zapier or per-credit billing on Make, where a five-billable-step equivalent consumes 25 times its free allowance. Two cautions: OpenAI per-token spend is unmodeled here by design, and node churn is real — OpenAI V2 requires n8n 1.117.0+, and AI Agent v1 is slated for removal in n8n 3.0 — so pin versions before you depend on this.
📖 Related Reads
- NiteAgent — AI agent development, frameworks, and production patterns
Cross-links automatically generated from NoCode Insider.