AI-Powered Lead Routing: Score and Assign Leads in n8n
Most sales teams sort leads the same way: whoever sees the notification first takes a stab at it, or everything piles into a spreadsheet and gets triaged manually at the end of the day. Both approaches mean your best-fit leads sit waiting while the team chases contacts who submitted a demo form out of idle curiosity.
n8n can fix this. With an AI node in the middle of your intake pipeline, every lead gets scored on intent before a human ever looks at it — and the hot ones land in Slack or your CRM within seconds of the form submit.
Here is exactly how to build it.
What the Workflow Does
- A lead submits a form (or your CRM fires a webhook).
- n8n receives the payload and optionally enriches it with company data.
- An AI/LLM node reads the lead's message, job title, and company size, then returns a structured JSON score from 1 to 10 with a short rationale.
- An IF node branches on that score: hot (7–10) goes right to your Slack channel and creates a CRM deal; warm (4–6) gets tagged for nurture; cold (1–3) is logged and dropped into a low-priority queue.
Eight nodes total. No custom code required for the happy path.
Node-by-Node Build
1. Webhook — receive the lead
Add a Webhook node, set the method to POST, and copy the generated URL into your form tool (Tally, Typeform, a plain HTML form — all work). Give the path something readable like /lead-intake.
The webhook URL on your AgentRoost instance is public HTTPS by default, so you do not need to set up SSL or a reverse proxy.
2. Set — normalize the fields
Incoming payloads differ by form tool. A Set node gives you consistent field names for the rest of the workflow:
{
"name": "{{ $json.submitter_name }}",
"email": "{{ $json.email }}",
"company": "{{ $json.company_name }}",
"employees": "{{ $json.employee_count }}",
"title": "{{ $json.job_title }}",
"message": "{{ $json.how_can_we_help }}"
}
Adjust keys to match whatever your form actually sends.
3. HTTP Request — optional enrichment
If you have a Clearbit, Hunter, or Apollo key, insert an HTTP Request node here to pull company domain, industry, and headcount. Feed the response back into a second Set node to merge the enriched fields.
If you do not have an enrichment API, skip this and rely on what the form captures. The AI node still does useful scoring on message intent alone.
4. AI / LLM Node — the scoring step
This is the core. Add an AI Agent or Basic LLM Chain node (both are under the AI section in n8n's node panel). Set the model — on AgentRoost you pick from the built-in credential that is already connected to your included credits.
Set the System Prompt to something like:
You are a B2B sales qualification assistant.
Given a lead's details, return a JSON object with two keys:
"score" (integer 1-10, where 10 = strongest buyer intent),
"reason" (one sentence explaining the score).
Score higher for: clear pain described, decision-maker title,
company size >50, urgency language, specific use-case mentioned.
Score lower for: vague curiosity, student/freelancer signals,
competitor research language.
Return ONLY valid JSON. No preamble.
Set the User Message to:
Name: {{ $json.name }}
Title: {{ $json.title }}
Company: {{ $json.company }} ({{ $json.employees }} employees)
Message: {{ $json.message }}
The node returns something like:
{ "score": 8, "reason": "Decision-maker at a 200-person company describing a specific integration pain, with urgency language." }
5. Code (mini) — parse the score
Add a small Code node to pull the score out reliably:
const raw = $input.first().json.text ?? $input.first().json.output;
const parsed = JSON.parse(raw);
return [{ json: { ...($input.first().json), score: parsed.score, reason: parsed.reason } }];
This handles slight variations in which key the LLM node returns the text on.
6. IF — branch by score
Add an IF node with the condition:
{{ $json.score }} >= 7
- True branch → hot lead path
- False branch → warm/cold path
For a three-way split (hot / warm / cold), chain a second IF on the false branch checking >= 4.
7a. Hot lead path — Slack + CRM
On the true branch, add two parallel nodes:
Slack node → Send Message to #sales-hot-leads:
*New hot lead — score {{ $json.score }}/10*
{{ $json.name }} · {{ $json.title }} @ {{ $json.company }}
_{{ $json.reason }}_
Reply to: {{ $json.email }}
HubSpot / Pipedrive / HTTP Request node → Create deal or contact. Most CRMs have a native n8n node; use HTTP Request with your CRM's REST API if yours does not.
7b. Warm/cold path — nurture or log
Add a HubSpot (or similar) node to tag the contact with a nurture list, or simply write a row to a Google Sheets node for manual review later.
8. Respond to Webhook
If your form tool expects a 200 response, end both branches with a Respond to Webhook node returning {"status":"ok"}. Some tools will retry on timeout otherwise.
Realistic Configuration Tips
- Temperature: Set the LLM temperature to
0.2. You want consistent, predictable JSON — not creative variation. - Max tokens: 150 is enough. The response is always a small JSON object.
- Error handling: Enable Continue on Error on the AI node and the Code node, then add a fallback Set node that assigns
score: 5(neutral) when parsing fails. This prevents the whole workflow from stopping on a malformed LLM response. - Test with real messages: Open the n8n editor, pin a few actual form submissions as test data, and run the AI node in isolation first. Tweak the prompt until score distributions feel right before wiring up the Slack/CRM nodes.
How to Run This on AgentRoost
You get your own n8n instance — your login, your data, your workflows, on a public subdomain at https://<your-id>.agentroost.app. Self-hosting without the DevOps.
- Sign up and pick the n8n framework.
- Name your instance — it becomes your subdomain.
- Your n8n editor opens. The AI credential is already wired to included credits. No OpenAI account, no API key, no billing setup to configure.
- Build the workflow node by node (or paste a JSON export if you have one from a test environment).
- Copy the webhook URL and drop it into your form tool.
- Activate the workflow.
The AI scoring calls run against your included credits. If you want to switch models, change one dropdown — the rest of the workflow is untouched. Start at $19.99/mo all-in, 14-day money-back guarantee, cancel anytime.
Compare plans and get started · See the n8n framework details
What to Watch After Launch
Once live, check the execution log in your n8n editor after the first 20–30 leads. Look for:
- Score clustering: if everything lands 4–6, your prompt may be under-differentiating. Add sharper scoring criteria.
- Parse failures: if the Code node errors, the LLM returned non-JSON. Add a regex fallback or tighten the prompt with
"Return ONLY valid JSON, no markdown fences.". - False positives in hot leads: review Slack alerts manually for the first week to calibrate the
>= 7threshold. Moving it to>= 8tightens the hot bucket.
A well-tuned version of this workflow typically takes one person less than an hour to build and another day of calibration. After that it runs unattended, and your sales team stops triaging — they follow up on leads that are actually worth their time.
Frequently asked questions
Do I need an OpenAI API key for the AI scoring node?
Not on AgentRoost. Your n8n instance is pre-wired to included AI credits, so the AI/LLM node works out of the box. You pick the model from the dropdown and run it — no external API key to create, pay for, or rotate.
Which LLM model should I use for lead scoring?
A mid-range model like a Llama 3 70B or Mistral variant is usually the sweet spot — fast, cheap per call, and more than capable of reading a 200-word lead message and returning a JSON score. You can switch models anytime in the n8n credential/model selector on AgentRoost without touching your workflow logic.
Can this workflow handle high lead volume without me managing infrastructure?
Yes. Your AgentRoost n8n instance runs 24/7 on dedicated hardware. Webhooks stay live around the clock. If volume spikes, upgrade to a Plus or Pro plan for more compute — no server wrangling involved.
How do I get my leads data into the workflow?
The most common entry points are a Webhook node (form tools like Typeform, Tally, or a custom HTML form POST to the webhook URL), a scheduled HTTP Request node polling your CRM API, or a direct CRM trigger if your tool supports webhooks natively. All of these are standard n8n nodes.
Can I cancel if the workflow doesn't work for my use case?
Yes. AgentRoost subscriptions are monthly with a 14-day money-back guarantee. Cancel anytime from your dashboard — no contract, no notice period.