Manual lead qualification and CRM updates can become a surprisingly expensive time sink for early-stage SaaS and engineering teams.
The workflow is usually the same:
A lead submits a form → someone checks the company → someone researches the role and company size → someone decides whether the lead matches the ICP → someone updates the CRM or alerts sales.
You can automate most of that pipeline with n8n, a company enrichment API, and an LLM-based evaluation step.
In this guide, we'll build the architecture behind an autonomous B2B lead qualification workflow, look at the evaluation prompt, and walk through the n8n workflow structure.
The goal isn't to make the LLM "decide everything." The goal is to give it structured inputs, explicit qualification rules, and a predictable output that downstream automation can consume.
1. System Architecture
The pipeline processes an inbound lead through four stages:
[ Inbound Lead Webhook ]
│
▼
[ Domain & Company Enrichment ]
│
▼
[ AI / ICP Evaluation ]
│
▼
[ Alert + CRM Routing ]
1. Webhook ingestion
The workflow starts when a lead submits a form, signs up for your application, or sends data from another system.
Example payload:
{
"email": "alex@example.com",
"name": "Alex Morgan",
"role": "CTO"
}
2. Company enrichment
The workflow extracts the domain from the email address and sends it to an enrichment provider.
Depending on the provider, you can retrieve information such as:
- Company name
- Industry
- Employee count
- Domain status
- Funding information
- Company description
This gives the AI evaluator more context than the original form submission alone.
3. ICP evaluation
The enriched lead is passed to an LLM agent.
Instead of asking:
"Is this a good lead?"
we provide explicit qualification criteria and require a structured response.
4. Automated routing
The result can then be used by n8n to:
- Send a Slack or Telegram notification
- Create or update a CRM record
- Add the lead to a nurture sequence
- Assign a sales priority
- Store the evaluation in PostgreSQL
2. Designing the ICP Evaluation Prompt
The most important part of this workflow isn't the AI model itself.
It's the contract between the AI and the automation workflow.
A useful evaluation prompt should define:
- What data the model receives
- What qualifies as a good lead
- What it should do when information is missing
- Exactly what format it must return
For example:
Evaluate the incoming lead against our Ideal Customer Profile (ICP).
Input Data:
- Lead information: {{lead_data}}
- Enriched company data: {{company_data}}
Qualification Criteria:
1. Company size:
- More than 10 employees is a positive signal.
2. Role:
- CTO
- Founder
- Engineering Lead
- VP Product
3. Company:
- Must appear to be a commercial organization.
- Personal email domains should not receive a Hot classification.
4. Missing information:
- Do not invent missing company information.
- If important information cannot be verified, reduce confidence.
Return JSON only:
{
"score": "Hot | Warm | Unqualified",
"reasoning": "One sentence explaining the classification.",
"recommended_action": "Instant Demo | Add to Nurture | Drop"
}
The important part here is not the word "deterministic."
LLMs are probabilistic.
What we're actually doing is constraining the model's behavior with explicit rules and a structured output contract.
That makes the result much easier for an automation pipeline to consume.
3. Connecting the Workflow in n8n
The basic n8n workflow looks like this:
Webhook
│
▼
Extract Email Domain
│
▼
Company Enrichment API
│
▼
Merge Lead + Company Data
│
▼
AI ICP Evaluator
│
▼
Parse Structured Output
│
├── Hot ───────► Sales Alert
│
├── Warm ──────► Nurture / CRM
│
└── Unqualified ► Archive
One improvement I'd recommend over a single AI node is adding an explicit structured-output/parser step after the model.
That gives you a clear boundary between:
LLM output
↓
Validation
↓
Automation
If the model produces malformed JSON, the workflow can stop or retry instead of sending unexpected data into your CRM.
4. Example n8n Workflow Structure
A simplified workflow can look like this:
{
"name": "B2B Lead ICP Scoring",
"nodes": [
{
"name": "Lead Inbound Webhook",
"type": "n8n-nodes-base.webhook",
"parameters": {
"path": "lead-submit",
"httpMethod": "POST"
}
},
{
"name": "Company Enrichment",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "https://api.example.com/company"
}
},
{
"name": "ICP AI Evaluator",
"type": "@n8n/n8n-nodes-langchain.agent",
"parameters": {
"prompt": "Evaluate the lead against the defined ICP rules and return structured JSON."
}
},
{
"name": "Route Lead",
"type": "n8n-nodes-base.switch",
"parameters": {
"mode": "rules"
}
}
]
}
This is intentionally simplified because the exact n8n JSON depends on the versions of the nodes you're using and the credentials configured in your instance.
For a real deployment, you'll also need to configure:
- AI model credentials
- Enrichment API credentials
- Telegram/Slack credentials
- Output parsing
- Error handling
- CRM integration
5. Don't Let the AI Become a Single Point of Failure
One mistake I see in AI automation workflows is putting too much trust in the model.
For lead scoring, the AI should be one component inside a controlled pipeline.
For example:
Raw Lead
│
▼
Schema Validation
│
▼
Company Enrichment
│
▼
Rule-Based Checks
│
▼
AI Evaluation
│
▼
Output Validation
│
▼
Business Routing
This gives you multiple opportunities to reject bad input before it reaches your CRM.
You can also keep hard business rules outside the model.
For example:
IF email domain is gmail.com
→ do not classify as Hot
IF employee_count < 10
→ reduce qualification priority
IF role = CTO
→ add positive signal
The LLM can handle the less structured reasoning, while explicit rules handle things that should never be ambiguous.
6. Production Considerations
Once the workflow starts receiving real traffic, there are a few additional concerns.
Queue-based execution
For higher webhook volume, n8n can be deployed using queue-based execution with Redis and worker processes.
This separates incoming webhook handling from workflow execution and can help handle bursts more reliably.
Secrets
Don't hardcode API keys inside workflow definitions.
Store credentials using n8n's credential system or your deployment's secret-management approach.
Rate limiting
Your enrichment and LLM providers will have their own limits.
Add rate limiting and retry strategies so a burst of inbound leads doesn't unexpectedly consume your entire API quota.
Error handling
External APIs fail.
LLM calls can time out.
Enrichment data can be incomplete.
A production workflow should define what happens when each of these situations occurs.
For example:
Enrichment API fails
│
▼
Retry
│
┌────┴────┐
│ │
Success Failure
│ │
▼ ▼
Continue Queue / Review
7. Where This Gets Interesting
Once the basic lead-scoring workflow works, you can extend it considerably.
For example:
Lead enrichment
Email
↓
Company
↓
Employees
↓
Industry
↓
Funding
↓
Technology Stack
AI qualification
Firmographics
+
Role
+
Company Description
+
Inbound Message
↓
ICP Score
Automated routing
Hot
├── Slack Alert
├── CRM Priority = High
└── Sales Notification
Warm
└── Nurture Sequence
Unqualified
└── Archive
At that point, n8n becomes less of a simple workflow builder and more of an orchestration layer around your AI services and business logic.
8. Final Architecture
The complete architecture can be summarized as:
┌─────────────────────┐
│ Lead Submission │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Schema Validation │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Company Enrichment │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Rule-Based Checks │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ AI ICP Scoring │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Output Validation │
└──────────┬──────────┘
│
┌──────────┼──────────┐
▼ ▼ ▼
Hot Warm Unqualified
│ │ │
▼ ▼ ▼
Sales Nurture Archive
The main lesson is that you don't need to make the LLM responsible for the entire process.
Use code for strict rules, APIs for enrichment, LLMs for flexible evaluation, and n8n for orchestration.
That separation makes the system easier to debug, test, and modify as your ICP changes.
Want the Full Automation Vault?
If you want to build beyond lead qualification, I packaged a collection of reusable n8n + AI workflows covering areas such as:
- Lead qualification
- Document RAG
- GitHub issue triaging
- Competitor monitoring
- Customer churn workflows
- AI-powered business automation
Enterprise n8n & AI Agent Automation Vault
https://nexusbuilds.gumroad.com/l/n8n-ai-automation-vault/EARLYBIRD
For the prompt-engineering rules used to structure AI coding and agent workflows, you can also check out the open-source repository:
Developer Prompt Vault
https://github.com/AymaneWebDEV/developer-prompt-vault
If you're building something similar, I'd be interested to know how you're handling AI scoring vs. rule-based qualification in your own automation stack.
Top comments (0)