Every freelancer, agency, and SaaS founder has the same problem: finding qualified leads takes hours of manual research, copy-pasting between tabs, and writing outreach emails that sound like they were written by a robot.
What if your lead pipeline ran itself?
In this tutorial, I'll walk you through building a complete AI-powered lead generation pipeline using n8n — the open-source workflow automation platform. By the end, you'll have a system that:
- Finds potential leads from a data source (Google Maps, Apollo, or a CSV)
- Enriches each lead with AI-generated insights
- Scores them based on your Ideal Customer Profile (ICP)
- Drafts personalized outreach emails
- Logs everything to a Google Sheet or database
No paid tools required beyond n8n (self-hosted or cloud) and an OpenAI API key.
Why n8n for Lead Generation?
If you've used Zapier or Make, you already understand workflow automation. n8n takes it further:
- Self-hosted option — your data never leaves your server
- No execution limits on the self-hosted version
- Native AI nodes — built-in support for OpenAI, Anthropic, and local LLMs
- AI Agent node — lets you build autonomous agents that reason through multi-step tasks
- 700+ integrations out of the box
- Fair-code license — free to use, inspect, and modify
For lead generation specifically, n8n shines because you can chain AI operations (enrichment, scoring, email drafting) without writing a single line of code, while keeping full control of the data flow.
Architecture Overview
Here's what we're building:
[Trigger] → [Lead Source] → [AI Enrichment] → [Lead Scoring] → [Email Draft] → [Output]
Nodes breakdown:
| Step | Node Type | Purpose |
|---|---|---|
| 1 | Schedule Trigger / Webhook | Kicks off the pipeline |
| 2 | HTTP Request / Google Sheets | Pulls raw lead data |
| 3 | OpenAI Node | Enriches leads with company research |
| 4 | Code Node | Scores leads against your ICP |
| 5 | OpenAI Node | Writes personalized outreach |
| 6 | Google Sheets / Gmail | Stores results and optionally sends |
Let's build each step.
Step 1: Set Up the Trigger
Start by creating a new workflow in n8n. Add a Schedule Trigger node so your pipeline runs automatically — daily is a good starting cadence.
Configuration:
- Trigger interval: Every 1 day
- Time: 09:00 AM (catch prospects at the start of their workday)
Alternatively, use a Webhook node if you want to trigger the pipeline on demand (e.g., from a form submission or API call).
Step 2: Pull Your Lead Data
You need a source of raw leads. Here are three approaches ranked by complexity:
Option A: Google Sheets (Simplest)
If you already have a list of companies or contacts, load them from a Google Sheet. Add a Google Sheets node:
- Operation: Read rows
- Sheet: Your lead list
- Expected columns:
company_name,website,industry,contact_email
Option B: HTTP Request to an API
Use the HTTP Request node to pull leads from APIs like:
- Apollo.io (free tier: 50 credits/month)
- Hunter.io (free tier: 25 searches/month)
- Google Maps API (for local businesses)
Example Apollo API call:
{
"method": "POST",
"url": "https://api.apollo.io/v1/mixed_people/search",
"headers": {
"x-api-key": "{{ $env.APOLLO_API_KEY }}"
},
"body": {
"person_titles": ["CEO", "Founder", "Head of Marketing"],
"organization_num_employees_ranges": ["1,50"],
"person_locations": ["Italy"]
}
}
Option C: Web Scraping with Code Node
For maximum flexibility, use a Code node to scrape data from directories, LinkedIn search results, or industry listings. Keep it ethical — respect robots.txt and rate limits.
Step 3: AI Enrichment
This is where the pipeline gets powerful. For each lead, we use AI to research the company and extract actionable insights.
Add an OpenAI node (or Anthropic, if you prefer Claude) and configure it:
Model: gpt-4o-mini (cost-effective for bulk processing)
System prompt:
You are a B2B research analyst. Given a company name and website,
provide a brief analysis including:
1. What the company does (1 sentence)
2. Their likely pain points related to automation
3. A personalization hook for cold outreach
4. Industry category
Respond in JSON format with keys: summary, pain_points, hook, industry
User message:
Company: {{ $json.company_name }}
Website: {{ $json.website }}
Important: Add a Wait node (1-2 seconds) between API calls to avoid rate limits when processing large batches. Alternatively, use n8n's built-in batch processing by setting the "Execute Once" option to false.
The output gives you structured intelligence on every lead — something that would take a human researcher 10-15 minutes per company.
Step 4: Lead Scoring
Not every lead is worth pursuing. Add a Code node to score leads against your Ideal Customer Profile.
const lead = $input.first().json;
let score = 0;
// Industry fit (customize these)
const targetIndustries = ['saas', 'ecommerce', 'marketing', 'consulting'];
if (targetIndustries.some(i => lead.industry?.toLowerCase().includes(i))) {
score += 30;
}
// Company size fit
const employees = lead.employee_count || 0;
if (employees >= 5 && employees <= 50) {
score += 25; // Sweet spot for automation services
} else if (employees > 50 && employees <= 200) {
score += 15;
}
// Has pain points related to automation
if (lead.pain_points?.toLowerCase().includes('manual')) {
score += 20;
}
if (lead.pain_points?.toLowerCase().includes('time')) {
score += 15;
}
// Has a website (basic qualification)
if (lead.website) {
score += 10;
}
return {
...lead,
lead_score: score,
priority: score >= 60 ? 'high' : score >= 35 ? 'medium' : 'low'
};
Add an IF node after scoring to filter: only pass through leads with priority === 'high' or priority === 'medium'. Don't waste AI credits writing emails for low-quality leads.
Step 5: AI-Powered Outreach Drafts
For qualified leads, add another OpenAI node to draft personalized outreach:
System prompt:
You are an outreach copywriter for an AI automation agency. Write a
short, personalized cold email (max 150 words) that:
- References something specific about their company
- Identifies a pain point they likely have
- Proposes automation as a solution
- Ends with a soft CTA (no hard sell)
Tone: Professional but human. No buzzwords. No "I hope this email
finds you well."
User message:
Company: {{ $json.company_name }}
Summary: {{ $json.summary }}
Pain points: {{ $json.pain_points }}
Personalization hook: {{ $json.hook }}
Contact name: {{ $json.contact_name }}
The AI generates a unique, relevant email for each lead — not a mail-merge template, but genuinely personalized copy based on research.
Step 6: Output and Storage
Finally, store everything in a Google Sheets node:
- Company name, website, contact info
- AI enrichment data
- Lead score and priority
- Draft email copy
- Timestamp
Create columns for status (new / contacted / replied / converted) so you can track your pipeline over time.
Optional: Add a Gmail node to automatically send high-priority outreach. But I recommend reviewing drafts manually for the first week until you trust the AI's output quality.
Advanced: Making It Smarter Over Time
Once your basic pipeline works, here are upgrades worth adding:
1. Duplicate Detection
Add a Google Sheets lookup at the start to check if a lead already exists. Skip duplicates to avoid embarrassing double-outreach.
2. Follow-Up Sequences
Create a separate workflow that checks your sheet for leads with status: contacted that haven't replied in 3 days, then generates a follow-up email.
3. Response Monitoring
Use a Gmail Trigger node to watch for replies. When a lead responds, automatically update their status and notify you via Slack or Telegram.
4. AI Agent for Research
Replace the simple OpenAI node with n8n's AI Agent node. Give it tools (web search, website scraper) and let it autonomously research each company — producing much richer enrichment data.
Real Numbers: What to Expect
Based on running this pipeline for client projects:
- Processing speed: ~200 leads/hour (with API rate limiting)
- AI enrichment cost: ~$0.002 per lead with GPT-4o-mini
- Email personalization cost: ~$0.003 per lead
- Total cost for 1,000 leads: Under $5
- Response rates: 8-15% (vs. 1-3% for generic templates)
The ROI math is straightforward: if you close even one client from a batch of 500 leads, and that client is worth more than $5, you're profitable.
Want the Ready-Made Workflow?
Building this from scratch is a great learning exercise, but if you want to skip the setup and start generating leads today, we've packaged production-ready versions of this pipeline:
AI Client Pipeline — Lead to Review Automation includes the complete workflow described in this article, pre-configured with error handling, retry logic, duplicate detection, and detailed documentation. Import it into n8n and customize it for your ICP in under 30 minutes.
If you're just getting started with n8n automation and want a broader foundation, the AI Automation Starter Pack bundles three production-ready n8n workflows covering lead generation, client onboarding, and review collection — everything an agency or freelancer needs to automate their client pipeline end-to-end.
Key Takeaways
- n8n + AI = scalable lead generation without expensive tools like Clay or Instantly
- Lead scoring is non-negotiable — qualify before you personalize to save time and money
- AI-written outreach outperforms templates when given proper context from the enrichment step
- Start simple, iterate — get the basic pipeline working before adding agents and follow-up sequences
- Self-host n8n if you're processing any volume — no execution limits, full data control
The best part? Once this runs, it keeps finding leads while you focus on closing deals and delivering work.
Built by Altiora — we build AI automation systems so you don't have to.
Top comments (0)