Automated B2B outreach pipeline built with n8n, OpenAI GPT-4o-mini, Apollo.io, Gmail and Google Sheets
Manual B2B lead generation is time-consuming, inconsistent, and difficult to scale. Sales teams spend hours finding contacts, writing personalized emails, tracking outreach, and managing follow-ups — all done manually with high risk of duplicate outreach and missed leads.
This project automates the entire outreach pipeline — from lead sourcing to personalized email delivery — using n8n as the automation backbone and OpenAI GPT-4o-mini for AI-powered personalization.
This pipeline automates the entire B2B outreach process — from lead sourcing to personalized email delivery — without any manual intervention.
Target use case: Reaching Amazon FBA founders, brand owners, and eCommerce entrepreneurs at scale.
| Stage | Node | Description |
|---|---|---|
| 1 | HTTP Request | Fetches contacts from Apollo.io via REST API |
| 2 | Split Out | Splits contact array into individual leads |
| 3 | Google Sheets | Loads previously contacted leads for dedup |
| 4 | Merge | Filters out already-contacted leads |
| 5 | AI Agent (GPT-4o-mini) | Generates personalized email per lead |
| 6 | Google Sheets | Logs each lead with timestamp and status |
| 7 | Gmail | Sends personalized email automatically |
- Manual Trigger / Schedule Trigger
- HTTP Request — Apollo.io API calls
- Edit Fields (Set) — Data transformation
- Split Out — Array to individual items
- Google Sheets (Get Rows + Append Row)
- Merge — Deduplication logic
- AI Agent + OpenAI Chat Model
- Gmail — Send message
The following describes the complete node chain in the n8n canvas:
Start Pipeline → Fetch Apollo Contacts → Extract Contacts Array → Split Into Individual Leads
Load Contacted Leads (Google Sheets) → Filter Already Contacted (Merge) → AI Email Writer (AI Agent + GPT-4o-mini) → Log Lead to Tracker (Google Sheets) → Send Outreach Email (Gmail)
- Automation Engine: n8n (Docker, localhost:5678)
- Lead Source: Apollo.io (contacts/search API)
- AI Model: OpenAI GPT-4o-mini
- Email Delivery: Gmail (Google OAuth)
- CRM/Tracker: Google Sheets
- Deduplication: n8n Merge node (field matching on email)
- Fully automated end-to-end pipeline
- AI-personalized emails per contact (name, title, company)
- Built-in deduplication — no lead contacted twice
- Audit trail in Google Sheets with timestamps
- Modular design — each stage independently swappable
- Scalable — supports up to 30 leads per run; increase
per_pageto scale
- Install n8n via Docker:
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n- Import
workflow/lead_gen_pipeline.jsoninto n8n - Add credentials: Apollo.io API key, OpenAI API key, Gmail OAuth, Google Sheets OAuth
- Create a Google Sheet named "Lead Tracker Apollo" with columns: Email, Name, Company, Status, Date Contacted
- Click "Execute workflow"
Apollo Free Plan API Restrictions
- Challenge: The
mixed_people/api_searchendpoint (People Search) requires a paid Apollo plan. Attempting to use it returned a 403 Forbidden error. - Solution: Switched to the
contacts/searchendpoint, which is available on the free plan and queries the account's saved contacts. Leads are manually saved via Apollo's web UI, then processed automatically by the pipeline.
Email Field Unavailable on Free Plan
- Challenge: Apollo's free plan does not return email addresses via the API. The email field returns as undefined.
- Solution: For portfolio demonstration, the pipeline architecture is complete and functional. The Gmail node is configured with a fallback email for testing. Upgrading to a paid Apollo plan or integrating Hunter.io would resolve this in production.
Data Path Lost After Multiple Nodes
- Challenge: After passing through the Google Sheets logging node, the AI Agent's output field (
$json.output) became inaccessible in the Gmail node. - Solution: Used n8n's node reference syntax
$('AI Agent').item.json.outputto explicitly reference the AI Agent node's output regardless of intermediate nodes.
- REST API integration — Apollo.io HTTP Request with master key authentication and custom headers
- Data transformation — array extraction, splitting, and field mapping across nodes
- AI prompt engineering — context-aware personalization using GPT-4o-mini
- Deduplication logic — Merge node with field matching across two data streams
- Google Sheets as lightweight CRM — read, compare, and append operations
- Email automation — Gmail OAuth integration with dynamic content
- End-to-end pipeline thinking — sourcing → filtering → personalization → logging → delivery
- Add follow-up email sequence — trigger 3 days after initial send if no reply
- Integrate Hunter.io for email finding on free tier
- Add Calendly link in outreach email for direct booking
- Switch trigger to Schedule node for fully automated daily runs
- Add error handling nodes for failed email sends
- Expand to LinkedIn outreach using Phantombuster integration
Isha, AI Automation Engineer