GUIDE · N8N

n8n webhook + AI agent: sort form leads automatically

14 min read·Updated 24 September 2026·n8n · Mistral · Slack · Google Sheets · Gmail
n8n workflow: Formdall Webhook, Lead triage agent with Mistral, Route by score splitting into Slack and Google Sheets for hot leads, a Gmail draft for warm leads, and a drop branch for junk.

Three inquiries in your inbox, and only one of them is a real job. This guide connects your contact form to an n8n webhook, and an AI agent sorts every inquiry. Concrete projects land in Slack and in a Google Sheet. Vague questions get a reply drafted in Gmail, ready for you to finish. Cold pitches never reach your team. In our demo run, a lead took under 2.4 seconds from submission to routing decision. Build it step by step, or import the finished workflow into n8n.

Spam filters stop bots, not people

Here are three inquiries from the same morning. Julia Becker from Möbelhaus Becker needs a new online shop for about 400 products by the end of November. Her budget is 15,000 to 20,000 euros, and she asks for a call next week. Tom Richter runs a small yoga studio and is thinking about a new website “at some point”. Kevin Marsh from Growth Leads Ltd promises first-page Google rankings for $299 a month.

All three are written by people. All three pass every spam filter, because none of them is spam. Julia’s inquiry is worth a call today. Tom’s deserves a friendly answer this week. Kevin’s deserves nothing.

Sorting them by hand works for five messages a week. At fifty, the good lead waits behind the pitches. This workflow does the sorting for you.

What you build

One submission takes this path:

  1. Your contact form posts to Formdall.
  2. Formdall runs its spam checks and stores the submission in your inbox.
  3. A webhook action sends it to your n8n webhook as JSON, with a bearer token.
  4. An AI agent in n8n reads the message and returns a score: hot, warm or junk.
  5. A Switch node routes on that score.

Each score has its own outcome. A hot lead posts to your sales channel in Slack and adds a row to a Google Sheet. A warm lead gets a Gmail draft with a reply the agent has written for you. A junk lead ends right there.

The work splits cleanly between two filters. Formdall stops the bots: automated posts, payloads that do not match the form, and disposable addresses - a check that is on by default and can be switched off per form. The AI agent sorts out the human noise: vendor pitches, job applications and requests you do not take on. Each filter handles what the other cannot.

The agent runs on Mistral, an EU model. OpenAI, Anthropic’s Claude or Google Gemini work the same way: n8n has a chat model node for each of them.

Why not post straight to the n8n webhook?

Your form could post straight to the n8n webhook. It saves one hop. Three reasons not to.

Bots find public webhooks. A form that posts from the browser puts the webhook URL into your page source. Any credential you add sits right next to it. Every bot hit starts an execution, and every execution calls the AI model. With Formdall in front, we run the spam checks before any action. Only submissions that pass them reach n8n.

n8n is sometimes down. Updates, restarts and a full disk all happen on self-hosted instances. A direct POST that hits a stopped instance is gone. We keep the submission in your inbox and deliver it again: 3 attempts in total, the second 10 seconds after the first one fails, the third 60 seconds after the second one fails.

A form needs more than a receiver. Someone has to validate the fields, send the visitor to your thank-you page and email you when a lead arrives. Formdall does all three, so your n8n workflow only does the sorting.

n8n Form Trigger or a form on your own site?

n8n has its own forms. The Form Trigger node builds a form from the fields you define and serves it at a URL on your n8n instance. For internal forms, that is the right tool. A vacation request, an equipment order or an onboarding checklist needs no custom design. Its link stays inside your team, and the node can ask for a login first, with Basic Auth or n8n User Auth. Bots rarely get to it. The Form Trigger gives you the form and the workflow in one node.

A contact form on your website is a different job. It sits in your own markup and your own design, next to your content. Strangers fill it in, and so do bots. That is where a form backend belongs in front of the n8n webhook: your form stays yours, and n8n receives only the submissions worth processing.

Step 1: Create the n8n webhook

The Webhook node gives your workflow a URL that Formdall can post to.

Create a new workflow in n8n and add a Webhook node. Its name matters: expressions in Step 4 address it as $('Formdall Webhook'), so name it exactly Formdall Webhook. The settings:

  • HTTP Method: POST
  • Path: formdall-leads
  • Authentication: Header Auth
  • Respond: Immediately. Formdall gets its HTTP 200 at once and does not wait for the agent.
  • Options: add Raw Body and switch it on. The optional signature check at the end needs the untouched bytes.

For Credential for Header Auth, create a new Header Auth credential. Its Name is Authorization, its Value is Bearer followed by a long random token. Keep the token at hand for Step 2. From now on, n8n turns away every request that does not carry this exact header.

The n8n Webhook node: Production URL selected, HTTP Method POST, Path formdall-leads, Authentication Header Auth with the credential Formdall bearer, Respond Immediately and the Raw Body option switched on.

At the top of the node, select Production URL and copy the address. The Test URL only listens while the editor waits for a test event, so deliveries from Formdall would miss it. The production URL goes live once you publish the workflow at the end of Step 4. On a self-hosted instance, set WEBHOOK_URL to your public address so the node shows the right one.

Step 2: Add the webhook action in Formdall

The webhook action sends every submission of your form to the n8n webhook.

Open your form in Formdall and add an action of type Webhook. Fill in these fields:

  • Endpoint URL: the production URL from Step 1.
  • Method and Content type: keep POST and application/json.
  • Authentication: Bearer token. Paste only the token, without the word Bearer. Formdall sends it as Authorization: Bearer <token>, which is exactly the header your n8n credential expects.
  • Conditions: message is not empty. A submission without a message gives the agent nothing to read, so it should not start an execution.

The webhook action in Formdall: Endpoint URL pointing to the n8n webhook, POST with application/json, an empty body template, Bearer token authentication, the signing secret and the condition message is not empty.

Leave Body template empty, because the agent’s prompt reads the standard body:

Standard body
{
  "form": { "name": "Kontakt", "key": "..." },
  "submitted_at": "2026-09-23T21:44:50+00:00",
  "data": { "name": "...", "email": "...", "company": "...", "message": "..." }
}

n8n puts the parsed JSON under body, so the form fields sit at $json.body.data. The action also gets its own Signing secret. You only need it for the optional signature check further down.

Step 3: Score the lead with an AI agent

The AI Agent node reads the message and returns a score plus three fields your team can act on.

Add an AI Agent node after the webhook and name it Lead triage agent. Set Source for Prompt (User Message) to Define below and paste this into Prompt (User Message):

Prompt (User Message)
New inquiry from the contact form on our website.

Name: {{ $json.body.data.name }}
Email: {{ $json.body.data.email }}
Company: {{ $json.body.data.company }}
Message:
{{ $json.body.data.message }}

Next, switch on Require Specific Output Format. It adds the output parser slot you fill further down. Under Options, add System Message and replace the default with this:

System Message
You triage inbound inquiries for a small web agency that builds websites and web apps for businesses.

Classify the inquiry into exactly one score:
- "hot": a concrete project or budget, a deadline, or a direct request for a quote or call.
- "warm": a genuine prospect who is still vague, exploring, or asking general questions.
- "junk": not a prospect. This includes vendor and agency pitches (SEO, marketing, lead lists, outsourcing), partnership or link-building offers, job applications, and requests unrelated to our services.

Also return:
- category: a 1-3 word label for what the inquiry is about.
- summary: one sentence a salesperson can read in two seconds.
- reply_draft: for "warm" only, a short, friendly reply in the language of the inquiry that answers what can be answered and asks one question to move forward. Empty string otherwise.

Never invent facts about our prices or availability.

The system message names the human noise one by one: vendor and agency pitches, partnership offers, job applications and unrelated requests. A polite pitch sounds a lot like a prospect. The list gives the model a clear line to decide on.

The AI Agent node: the prompt defined below with the lead’s name, email, company and message, Require Specific Output Format switched on, and the system message with the rules for hot, warm and junk.

Below the agent sit two slots, and each needs a sub-node:

  • Chat Model: a Mistral Cloud Chat Model with the model ministral-14b-latest. Its credential takes your Mistral API key. The model list fills in once the key is saved.
  • Output Parser: a Structured Output Parser. Set Schema Type to Define using JSON Schema and paste the schema below.
Structured Output Parser schema
{
  "type": "object",
  "properties": {
    "score": { "type": "string", "enum": ["hot", "warm", "junk"] },
    "category": { "type": "string" },
    "summary": { "type": "string" },
    "reply_draft": { "type": "string" }
  },
  "required": ["score", "category", "summary", "reply_draft"]
}

The parser holds the model to exactly these four fields. The agent returns them under output, so the next node reads the score as $json.output.score. Ministral 14B runs on Mistral’s free plan. On a paid plan, a larger model such as Mistral Small or Medium plugs into the same node. If you prefer OpenAI, Anthropic or Google Gemini, connect their chat model to the same slot and keep the prompt and the schema.

This is what the agent returned for Julia’s inquiry in our demo run:

Output of the Lead triage agent in n8n, JSON view: output with score hot, category eCommerce website, a one-sentence summary of Julia’s inquiry and an empty reply_draft.

Agent output for Julia Becker
{
  "output": {
    "score": "hot",
    "category": "eCommerce website",
    "summary": "Möbelhaus Becker needs a new online shop for ~400 furniture items by November, budget €15-20k, and wants to call next week.",
    "reply_draft": ""
  }
}

Step 4: Route by score

The Switch node sends each lead down one of three branches.

Behind the agent comes a Switch node named Route by score. Keep Mode on Rules and add three routing rules. Each compares {{ $json.output.score }} with is equal to against hot, warm or junk. Switch on Rename Output in each rule and enter the same word as Output Name. The canvas then labels every branch.

The Switch node in Rules mode with three routing rules: the expression $json.output.score is equal to hot, warm and junk, each with Rename Output on and a matching output name.

Each branch gets its own nodes. After the agent, the form fields are no longer in $json, so these nodes read them from Formdall Webhook by name.

hot: Slack and Google Sheets. A Slack node named Notify sales sends a message. Set Resource to Message and Operation to Send. Then set Send Message To to Channel, Channel to #sales, and Message Text to:

Message Text
:fire: {{ $json.output.summary }} - {{ $('Formdall Webhook').item.json.body.data.email }}

Behind it, a Google Sheets node named Log lead appends a row. Set Resource to Sheet Within Document and Operation to Append Row. Pick your spreadsheet under Document and the tab Leads under Sheet. The tab needs the headers date, name, email, category and summary in its first row. Set Mapping Column Mode to Map Each Column Manually and fill in the columns like this:

Log lead columns
date: {{ $('Formdall Webhook').item.json.body.submitted_at }}
name: {{ $('Formdall Webhook').item.json.body.data.name }}
email: {{ $('Formdall Webhook').item.json.body.data.email }}
category: {{ $('Lead triage agent').item.json.output.category }}
summary: {{ $('Lead triage agent').item.json.output.summary }}

warm: a Gmail draft. A Gmail node named Draft reply uses the resource Draft and the operation Create. Set Subject to Re: your inquiry and Message to {{ $json.output.reply_draft }}. Under Options, add To Email with {{ $('Formdall Webhook').item.json.body.data.email }}. The draft waits in Gmail until you read it, adjust it and send it.

junk: nothing. A No Operation node named Drop ends the branch. The execution stays in the list, so you can check any verdict later.

Save the workflow and publish it. n8n only publishes when every node that needs one has a credential, so connect Slack, Google Sheets and Gmail first, or delete the nodes you do not use.

Step 5: Test it

Three test submissions, one per score, run every branch once.

Send these three through your contact form. They are the messages from the start of this guide:

  • Julia Becker: “Hallo, wir brauchen bis Ende November einen neuen Onlineshop für unsere Möbel, rund 400 Artikel. Budget liegt bei 15-20k. Können wir nächste Woche telefonieren?” In English: we need a new online shop for our furniture by the end of November, about 400 products. The budget is 15-20k. Can we talk on the phone next week?
  • Tom Richter: “Hi, I run a small yoga studio and I’m thinking about a new website at some point. What does something like that usually involve?”
  • Kevin Marsh: “We offer guaranteed first page results for just $299/month. Can I send you a free audit?”

In our demo run, we sent them 3 seconds apart. Each one landed on the branch it belongs to:

Lead Score Summary from the agent
Julia Becker hot Möbelhaus Becker needs a new online shop for ~400 furniture items by November, budget €15-20k, and wants to call next week.
Tom Richter warm Small yoga studio owner exploring website needs and process.
Kevin Marsh junk Outbound pitch from an SEO vendor offering guaranteed rankings and a free audit.

Julia wrote in German, and the agent still picked out her budget and her request for a call. For Tom, it also wrote a reply draft that ends with a question:

Hi Tom, thanks for reaching out! A website for a yoga studio typically includes pages like class schedules, instructor bios, and a way for students to book sessions. Do you have any specific features or design preferences in mind, or would you like us to share examples of work we’ve done for similar studios?

This is the timeline of Julia’s run:

Time (UTC) What happened
09:51:30 Formdall receives Julia’s submission
09:51:31.175 Formdall delivers, n8n receives the webhook
09:51:32.370 The agent returns hot
09:51:32.386 Route by score sends the lead down the hot branch

Formdall records the submission to the second. The other times come from the n8n execution. From submission to routing decision, the run took under 2.4 seconds. The call to the model took 1.1 of them.

Julia’s execution in n8n: green edges from Formdall Webhook through the Lead triage agent with the Mistral model and the Lead schema to Route by score and out of its hot output. Notify sales, Log lead, Draft reply and Verify signature are grey and marked Deactivated.

Slack, Google Sheets and Gmail were not connected in this demo run. We deactivated Notify sales, Log lead and Draft reply, so each run ended after the routing decision. n8n still draws the edge into a deactivated node, but the node does not run. With your credentials connected, a hot lead posts to #sales and adds a row to Leads, and a warm lead gets its Gmail draft.

In n8n, open the Executions tab of the workflow. Every submission shows up as one execution. Open it to see what each node received and returned, including the agent’s score and the branch the lead took.

In Formdall, the webhook action lists its recent deliveries. Success with HTTP 200 means n8n accepted the request. The three deliveries of the demo run are at the top, all at 11:51 local time (09:51 UTC).

Recent deliveries of the webhook action in Formdall: three deliveries on 24.09. at 11:51, each Success after 1 attempt with HTTP 200.

The Webhook node answers before the agent starts, because Respond is set to Immediately. A success in Formdall therefore means the lead reached n8n. The execution shows how the agent scored it.

Spam never reaches n8n

We run the spam checks before any action starts. A submission that fails them never reaches your webhook action. Bot traffic starts no execution and costs no AI credits. Throwaway addresses stop at the same point, on by default and switchable per form. More on the spam protection page.

Optional: verify the signature

The bearer token proves who is sending the request. The signature proves that the body is exactly what Formdall sent.

We sign every delivery with HMAC-SHA256 over the raw body, keyed with the action’s signing secret. The result travels in the X-Formdall-Signature header as sha256= plus the hex digest. A leaked token alone is then not enough to slip a fake lead into your pipeline.

The downloadable workflow already contains the check. A Code node named Verify signature sits between the webhook and the agent and is disabled. It needs Raw Body on the Webhook node, which you set in Step 1.

The node reads the secret from $env.FORMDALL_SIGNING_SECRET instead of carrying it in its code. A secret written into the node travels with every export of the workflow. On a self-hosted n8n, three environment variables make this work:

docker-compose.yml
environment:
  - NODE_FUNCTION_ALLOW_BUILTIN=crypto
  - N8N_BLOCK_ENV_ACCESS_IN_NODE=false
  - FORMDALL_SIGNING_SECRET=${FORMDALL_SIGNING_SECRET}

The first lets the Code node load crypto. The second allows $env in nodes, which n8n 2.x blocks by default. The third carries the signing secret from your Formdall action. Restart n8n afterwards.

This setup is for self-hosted n8n. On n8n Cloud, use n8n Variables if your plan includes Environments (n8n Cloud Pro and Enterprise). Create FORMDALL_SIGNING_SECRET there and change the line to const secret = $vars.FORMDALL_SIGNING_SECRET;. On other plans, paste the secret straight into the Code node instead. Then enable the node:

Verify signature (Code node)
// Formdall signs the raw body with the action's secret. Compare in constant
// time, and against the raw bytes - a re-serialised JSON object will not match.
const crypto = require('crypto');
const secret = $env.FORMDALL_SIGNING_SECRET;
const item = $input.first();
const raw = Buffer.from(item.binary.data.data, 'base64');
const header = item.json.headers['x-formdall-signature'] ?? '';
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(raw).digest('hex');
const ok =
  expected.length === header.length &&
  crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(header));
if (!ok) throw new Error('Invalid Formdall signature');
// Keep the webhook's item shape, so the agent's $json.body.data paths work
// whether this node is enabled or not. Only the body is swapped for the
// verified bytes.
return [{ json: { ...item.json, body: JSON.parse(raw.toString('utf8')) } }];

A request with a wrong or missing signature stops with the error Invalid Formdall signature. A valid one passes on with the same shape as before, so the agent’s $json.body.data paths keep working.

Download the workflow

Skip the building and import the finished workflow.

Download the n8n workflow (JSON)

In n8n, open the three-dot menu of a new workflow and select Import from File. The file carries no credentials, no webhook ID and no account data. After the import, reconnect these parts:

  • Formdall Webhook: a Header Auth credential with your token, as in Step 1.
  • Mistral Cloud Chat Model: your Mistral credential.
  • Notify sales: your Slack credential, and a channel other than #sales if yours is named differently.
  • Log lead: your Google Sheets credential, and your spreadsheet in place of YOUR_SHEET_ID.
  • Draft reply: your Gmail credential.

Then publish the workflow and paste its production URL into the Formdall action.

FAQ

Frequently asked questions

Does this work with n8n Cloud as well as self-hosted n8n?

Yes. Formdall only needs a public URL, and HTTPS is recommended. n8n Cloud gives you one. A self-hosted instance has to be reachable from the internet. We refuse private and local addresses, so an n8n on your laptop needs a tunnel such as ngrok.

What happens if my n8n instance is down?

The submission stays in your Formdall inbox. Delivery makes up to 3 attempts: the second 10 seconds after the first one fails, the third 60 seconds after the second one fails.

Can I send only some submissions to n8n?

Yes. Conditions on the webhook action decide whether it runs. Compare any field with equals, not equals, contains, starts with, is empty or is not empty. Several rules can require that all of them match, or that any one does.

Does a failed AI call show up in Formdall?

No. The Webhook node answers as soon as the request arrives, so Formdall records the delivery as a success. Anything that fails after that, such as the call to the model, shows up in the Executions tab in n8n.

Does this work with Make or Zapier?

Yes. The webhook action posts to any public URL. Point it at a webhook trigger in Make or Zapier, and the same JSON arrives there. The scoring step then runs in their tools instead of the n8n AI Agent.

Can I use OpenAI, Claude or Gemini instead of Mistral?

Yes. Swap the Mistral Cloud Chat Model for your provider's chat model node, such as OpenAI Chat Model, Anthropic Chat Model or Google Gemini Chat Model. The prompt and the schema stay the same. We tested the example with Mistral because it is an EU provider.

Put Formdall in front of your n8n webhook

Start for freeno credit card, ever
  • Free
  • 3 forms
  • 100 submissions/mo