Hey everyone! ![]()
I wanted to share a lightweight, self-hostable AI lead qualification workflow built with n8n, Google Gemini, and Google Sheets.
If you run an agency, freelance business, or SMB, inbound chat leads often require quick triage: asking what the prospect needs, gathering their budget/urgency, and recording their details without paying $100+/month for enterprise chat platforms.
Here is a step-by-step breakdown of how to build an interactive AI lead qualification bot in n8n.
Workflow Architecture
[ Visitor Chat Input ]
│
▼
1. n8n Chat Trigger ──► 2. AI Agent Node ◄── (Google Gemini Model + Window Memory)
│
▼
3. Parse Lead (Code Node)
│
▼
4. Reply to Visitor
│
▼
5. Completeness Check (If Node)
│
▼ (If Name + Email Present)
6. Google Sheets Logger
Key Technical Setup
1. AI Agent System Prompt:
You are a helpful, professional AI Lead Qualification assistant.
Your goal is to assist website visitors and gather key business details:
1. Contact Name
2. Email Address
3. Company / Project Scope
4. Estimated Budget
5. Implementation Urgency (e.g. Immediately, 1-3 months)
Guidelines:
- Keep responses concise (1-3 sentences max).
- Answer visitor questions about our services warmly.
- Seamlessly weave questions to collect missing contact or project details.
- Once you have collected Name and Email, thank the visitor and inform them our team will follow up shortly.
2. JavaScript Lead Extractor (Parse Lead Code Node):
const item = $input.first().json;
const text = item.output || item.response || "";
return {
json: {
raw_response: text,
extracted_at: new Date().toISOString(),
session_id: item.sessionId || $node["n8n Chat Trigger"].json.sessionId,
has_contact_info: (text.includes("@") || text.toLowerCase().includes("email"))
}
};
3. Google Sheets Destination:
Create a Google Sheet with columns: Timestamp | Session ID | Name | Email | Company | Budget | Urgency | Summary. Map the n8n Google Sheets node (Append Row) to these fields.
Costs & Performance
- Platform Fee: $0/mo (Self-hosted n8n / free cloud tier).
- AI Cost: Google Gemini 1.5 Flash generous free tier / fractions of a cent per session.
Pre-built Template (Optional)
If you’d like to jumpstart setup with the ready-to-import JSON workflow file, complete field-mapping Code node, and setup guide, I’ve packaged the complete template on Gumroad ($19):
AI Lead Qualifier Chatbot — n8n Template on Gumroad
(The breakdown above is 100% self-contained if you want to build it yourself from scratch in n8n!)
Let me know if you have any questions or feedback! Happy automating! ![]()