"Learn how to build an AI-powered lead qualification workflow with n8n, OpenAI, Webhooks, Google Sheets and Slack."
tags: n8n, ai, automation, tutorial
canonical_url: https://aiotagen.com/2026/08/17/n8n-vs-zapier-vs-make-2026/
Build an AI Lead Qualification Workflow with n8n — Complete Tutorial
Most businesses receive leads from websites, forms, WhatsApp, landing pages and other channels.
The problem usually starts after the lead arrives.
Someone has to read the enquiry, decide whether the lead is relevant, enter the information into a CRM or spreadsheet, notify the sales team and follow up.
This entire process can be automated with n8n + AI.
In this tutorial, we'll build a practical workflow that:
- Receives a lead through a Webhook
- Cleans and structures the lead data
- Uses AI to qualify the enquiry
- Calculates a lead score
- Categorizes the lead as hot, warm or cold
- Stores the lead
- Notifies the sales team
The same architecture can be adapted for agencies, SaaS companies, real estate businesses, clinics and other service businesses.
What We Are Building
The final workflow will look like this:
Lead / Website Form
↓
Webhook
↓
Normalize Data
↓
OpenAI / AI
↓
Lead Scoring
↓
Routing
↙ ↘
Store Notify
Lead Sales
Workflow Architecture
The important idea is that n8n becomes the orchestration layer between your lead source, AI model and business tools.
1. Requirements
You need:
- n8n
- An OpenAI API key
- Google Sheets or another database
- Slack or another notification channel
- A source that can send HTTP requests
You can run n8n using n8n Cloud or self-host it.
For this tutorial, we'll use:
n8n
OpenAI
Google Sheets
Slack
2. Create the Webhook
Start with a Webhook node.
Configure it approximately like this:
HTTP Method: POST
Path:
lead-intake
Authentication:
None
Response:
Immediately
The webhook will give you an endpoint that your website, application or form can call.
Example Request
curl -X POST \
https://YOUR-N8N-DOMAIN/webhook/lead-intake \
-H "Content-Type: application/json" \
-d '{
"name": "Sara Khan",
"email": "sara@example.com",
"company": "Example Agency",
"budget": 2500,
"message": "We need an AI automation system and would like a demo."
}'
Your Webhook node should now receive data similar to:
{
"name": "Sara Khan",
"email": "sara@example.com",
"company": "Example Agency",
"budget": 2500,
"message": "We need an AI automation system and would like a demo."
}
Webhook Configuration Visual
3. Normalize the Lead Data
Real-world lead data isn't always clean.
One form might send:
full_name
email_address
company_name
message
while another system might send:
name
email
company
message
Use an Edit Fields node to create a consistent structure.
For example:
{
"name": "={{ $json.name }}",
"email": "={{ $json.email }}",
"company": "={{ $json.company }}",
"message": "={{ $json.message }}",
"budget": "={{ $json.budget }}"
}
Keeping a predictable structure makes the rest of the workflow much easier to maintain.
4. Send the Lead to AI
Now add an OpenAI node.
The AI's job isn't to make the final sales decision.
Instead, it should analyze the enquiry and return structured information.
A useful prompt is:
You are a lead qualification assistant.
Analyze the following business lead.
Name:
{{ $json.name }}
Company:
{{ $json.company }}
Budget:
{{ $json.budget }}
Message:
{{ $json.message }}
Return JSON only.
Use this structure:
{
"summary": "short summary",
"intent": "what the lead wants",
"urgency": "low | medium | high",
"qualification": "qualified | not_qualified | needs_review",
"reason": "why this lead received this qualification"
}
For example, the AI might return:
{
"summary": "Agency looking for an AI automation system.",
"intent": "AI automation demo",
"urgency": "high",
"qualification": "qualified",
"reason": "The company has a clear requirement and an identified budget."
}
Structured output is important because the next nodes can work with individual fields instead of trying to interpret free-form text.
5. Add Lead Scoring with the Code Node
Now we can calculate a simple lead score.
Add an n8n Code node.
Use:
const lead = $json;
const text = String(lead.message ?? '').toLowerCase();
const budget = Number(lead.budget ?? 0);
let score = 0;
if (text.includes('demo')) {
score += 30;
}
if (text.includes('pricing')) {
score += 20;
}
if (text.includes('automation')) {
score += 20;
}
if (budget >= 1000) {
score += 30;
}
if (lead.company) {
score += 20;
}
const priority =
score >= 70
? 'hot'
: score >= 40
? 'warm'
: 'cold';
return [
{
json: {
...lead,
score,
priority
}
}
];
The result could look like:
{
"name": "Sara Khan",
"email": "sara@example.com",
"company": "Example Agency",
"budget": 2500,
"score": 100,
"priority": "hot"
}
Code Node Visual
6. Route Hot, Warm and Cold Leads
Now add an IF or Switch node.
For example:
priority = hot
can go directly to the sales notification.
You can create three routes:
HOT
↓
Sales notification
↓
Immediate follow-up
WARM
↓
CRM / spreadsheet
↓
Follow-up sequence
COLD
↓
Database
↓
Nurture campaign
This is where automation starts becoming useful from a business perspective.
Instead of treating every enquiry equally, the workflow creates different paths.
7. Store the Lead in Google Sheets
Add a Google Sheets node.
Create columns such as:
Name
Email
Company
Message
Budget
AI Summary
Qualification
Score
Priority
Created At
Then map the values from n8n:
Name → {{ $json.name }}
Email → {{ $json.email }}
Company → {{ $json.company }}
Message → {{ $json.message }}
Budget → {{ $json.budget }}
Score → {{ $json.score }}
Priority → {{ $json.priority }}
Now every lead is automatically stored.
No manual copy and paste is required.
8. Notify the Sales Team
For hot leads, add a Slack node.
A simple notification can be:
🔥 NEW HOT LEAD
Name: {{ $json.name }}
Company: {{ $json.company }}
Budget: {{ $json.budget }}
Score: {{ $json.score }}
Priority: {{ $json.priority }}
Message:
{{ $json.message }}
AI Summary:
{{ $json.summary }}
Your sales team can then respond while the lead is still active.
9. Complete Workflow
The complete workflow becomes:
┌──────────────┐
│ Webhook │
└──────┬───────┘
↓
┌──────────────┐
│ Edit Fields │
└──────┬───────┘
↓
┌──────────────┐
│ OpenAI │
│ AI Analysis │
└──────┬───────┘
↓
┌──────────────┐
│ Code │
│ Lead Scoring │
└──────┬───────┘
↓
┌──────────────┐
│ Switch │
└───┬──────┬───┘
↓ ↓
HOT WARM
↓ ↓
Slack Google Sheets
↓
Sales Team
This is a simple architecture, but it can be expanded significantly.
10. Improving the Workflow
Once the basic workflow works, you can add more automation.
CRM Integration
Instead of Google Sheets:
Webhook
↓
AI
↓
Lead Score
↓
HubSpot / Salesforce / Pipedrive
WhatsApp Follow-Up
You can add a WhatsApp API after qualification:
New Lead
↓
AI Qualification
↓
Hot Lead
↓
WhatsApp Message
Example:
Hi {{ $json.name }},
Thanks for contacting us.
We received your enquiry about AI automation.
Would you like to book a quick call with our team?
AI Calling
For businesses receiving large numbers of enquiries, an AI calling agent can be triggered when a lead reaches a particular score.
Lead
↓
AI Qualification
↓
Score >= 70
↓
AI Calling Agent
↓
Appointment
11. Add Error Handling
Production workflows should also handle failures.
For example:
OpenAI Error
↓
Error Workflow
↓
Slack Alert
↓
Log Error
You should also validate:
- Missing email addresses
- Invalid webhook payloads
- Empty messages
- API failures
- Duplicate leads
- Rate limits
For example, before sending the lead to AI:
const lead = $json;
if (!lead.email) {
throw new Error('Lead email is missing');
}
if (!lead.message) {
throw new Error('Lead message is missing');
}
return [
{
json: lead
}
];
This prevents bad data from silently moving through the workflow.
12. Security Considerations
If you're exposing an n8n Webhook publicly, don't treat it as an unrestricted endpoint.
For production systems, consider:
- Webhook authentication
- API keys
- Signature verification
- Rate limiting
- Input validation
- HTTPS
- Restricted credentials
- Proper error handling
Also avoid sending unnecessary sensitive information to an external AI provider.
Only send the data required for the automation.
13. Example Production Workflow
A more advanced version could look like this:
Website
↓
Webhook
↓
Validate Request
↓
Normalize Data
↓
Check Duplicate
↓
OpenAI Qualification
↓
Lead Scoring
↓
Switch
├── HOT
│ ↓
│ CRM
│ ↓
│ Slack
│ ↓
│ WhatsApp
│
├── WARM
│ ↓
│ CRM
│ ↓
│ Follow-up
│
└── COLD
↓
CRM
↓
Nurture
This architecture can handle much more than simply storing form submissions.
14. Why n8n Works Well for This
The advantage of n8n is that it can act as the layer connecting multiple systems.
For example:
Website
↓
n8n
├── OpenAI
├── Google Sheets
├── HubSpot
├── Slack
├── Gmail
├── WhatsApp
└── Calendar
Instead of building separate integrations for every part of the process, you can orchestrate the workflow from one place.
This is particularly useful when a business already uses several different SaaS tools.
Final Thoughts
AI automation doesn't have to start with a huge multi-agent system.
A simple workflow can already provide significant value:
Capture → Understand → Score → Store → Notify → Follow Up
Once that workflow is reliable, you can gradually add CRM integration, WhatsApp, appointment booking, AI calling and analytics.
The most important part is to start with a real business problem rather than adding AI simply because it is available.
If you're building your first n8n AI workflow, start small, test every node independently and add complexity only when the basic workflow is stable.
For more practical automation guides and workflow ideas, check out Aiotagen:
https://aiotagen.com/
Top comments (0)