Lead generation becomes difficult when enquiries arrive from multiple channels and someone has to manually read, qualify, copy, and assign every lead.
A simple automation can remove most of this repetitive work.
In this tutorial, we'll build an AI-powered lead qualification workflow with n8n.
The workflow will:
Receive a lead through a webhook
Extract useful information from the enquiry
Calculate a qualification score
Decide whether the lead is qualified
Prepare the lead for CRM/sales processing
Return a structured response
The architecture looks like this:
Lead Source
↓
Webhook
↓
AI / Lead Analysis
↓
Information Extraction
↓
Lead Scoring
↓
Qualified?
/ \
Yes No
↓ ↓
Sales Nurture
The advantage of this approach is that AI handles the understanding, while n8n handles the business logic.
What we'll build
Imagine a customer sends:
Hi, I'm looking for an AI chatbot for my real estate company in Dubai. We have around 500 enquiries per month and need something urgently. Our budget is around $2,000.
We want the automation to turn that unstructured message into something like:
{
"name": "Unknown",
"company": "Unknown",
"industry": "Real Estate",
"service": "AI Chatbot",
"location": "Dubai",
"budget": 2000,
"urgency": "High",
"leadScore": 90,
"qualified": true
}
The sales team doesn't need to manually interpret the original message.
- Create the n8n workflow
Create a new workflow in n8n.
Add a Webhook node.
Configure it as:
HTTP Method: POST
Path: lead-qualification
Response Mode: Last Node
Your webhook endpoint will look similar to:
https://your-n8n-domain.com/webhook/lead-qualification
For local development, you can use the test URL generated by n8n.
- Send a test lead
You can test the webhook with cURL.
curl -X POST "https://your-n8n-domain.com/webhook/lead-qualification" \
-H "Content-Type: application/json" \
-d '{
"name": "John Smith",
"company": "Example Property Group",
"message": "We are a real estate company in Dubai looking for an AI chatbot. Our budget is around $2000 and we need it urgently."
}'
The Webhook node will now receive the lead.
- Extract the lead information
Next, add a Code node.
Rename it:
Extract Lead Data
For this example, we'll use simple JavaScript to prepare the incoming data.
const lead = $json;
const name = lead.name || "";
const company = lead.company || "";
const message = lead.message || "";
return [
{
json: {
name,
company,
message,
receivedAt: new Date().toISOString()
}
}
];
This gives the rest of the workflow a predictable structure.
- Add AI-powered analysis
Now we can use an AI model to understand the customer's message.
You can use an OpenAI node or another LLM integration available in your n8n setup.
The important part is the prompt.
Use something similar to:
You are a lead qualification assistant.
Analyze the customer enquiry below.
Extract:
- industry
- service
- location
- budget
- urgency
- buying_intent
Return ONLY valid JSON.
Customer message:
{{ $json.message }}
A possible AI response would be:
{
"industry": "Real Estate",
"service": "AI Chatbot",
"location": "Dubai",
"budget": 2000,
"urgency": "High",
"buying_intent": "High"
}
For production systems, validate the AI response before allowing it to trigger business-critical actions.
- Calculate the lead score
Now we move the deterministic business logic into n8n.
Add another Code node called:
Calculate Lead Score
Example:
const lead = $json;
let score = 0;
if (lead.service) {
score += 30;
}
if (lead.budget) {
score += 20;