Automated Lead Acquisition & AI Outreach Pipeline
An end-to-end B2B automation system for configurable lead discovery, contact enrichment, prioritization, AI-assisted personalization, approval-controlled delivery, reply tracking, and automated follow-ups.
Role
Automation Engineer & Systems Designer
Tech Stack
The Challenge
The outreach process required multiple disconnected steps: identifying relevant companies, finding usable contact data, researching businesses, preparing personalized messages, controlling delivery, tracking replies, and manually handling follow-ups.
The goal was to turn this into a structured automation system while preserving human control over outbound communication. Each stage needed to be reliable, state-aware, and independently operable without tight coupling between workflow phases.
High-Level System Architecture
Eleven sequential stages, each implemented as an independent n8n workflow and coordinated through shared Google Sheets state.
Config-driven targeting via structured sheet
Outscraper API call per campaign keyword
Filter and validate location constraints
Resolve contact details and metadata
Score and rank leads for outreach order
Firecrawl scrapes site for context
OpenAI generates subject and body
Review column gates all outbound sends
Row lock → Gmail send → status sync
Incoming Gmail replies linked to thread
Contextual follow-up if no reply within window
Configurable Lead Acquisition
Campaign configuration drives the entire acquisition stage. No hard-coded values — targeting parameters, processing limits, and workflow behavior are managed through a structured control sheet.

▸Main lead acquisition workflow: campaign config read → Outscraper API call → async wait → geographic filter → contact enrichment → priority assignment → persist valid records.

▸Campaign control sheet managing target country, search keyword, processing limit, and campaign state — no hard-coded parameters in the workflow itself.
Structured Lead Data
The lead database stores enriched company and contact information alongside explicit operational workflow state — enabling each pipeline stage to read and update only what it owns.

▸Sanitized master leads database — enriched company and contact data with operational state columns tracking priority, outreach status, reply state, and processing progress. Sensitive data redacted.
AI Personalization
Eligible leads are researched using available business and website context via Firecrawl. OpenAI prepares a personalized outreach draft — subject and body — which is stored for human review before any message is sent.
AI generation and delivery are intentionally decoupled
The AI draft workflow writes to the email log and stops. A separate human-controlled workflow handles actual message delivery only after explicit approval. This separation is a deliberate architectural decision.

▸AI draft workflow: fetch eligible leads → Firecrawl website scrape → structured context extraction → OpenAI draft generation → split subject and body → log draft row → update lead status to 'Draft Ready'.
Human-Controlled Delivery
Approved messages move through a dedicated delivery workflow. Row locking prevents duplicate sends. State is synchronized across the email log and leads sheet on completion.
Human approval required
Email Log Review column must = 'Approved'
Row locked during send
Status set to 'Sending' before Gmail dispatch
Duplicate-send prevention
Locked rows are skipped by all subsequent runs
Synchronized state update
Email log and leads sheet both updated post-send

▸Delivery workflow: query approved emails → lock row with 'Sending' state → dispatch via Gmail → merge send result → update Email Log and Leads sheet status → mark first email sent flag.
Automated Follow-Up
When outreach has not received a reply within the configured wait window, the system can prepare contextual AI-assisted follow-up content and continue the existing Gmail thread — maintaining thread coherence.
The follow-up workflow identifies outreach records that have passed the elapsed wait period without a reply. It merges the original email context with AI-generated follow-up content, then sends within the same Gmail thread — preserving conversation continuity for the recipient.

▸Follow-up workflow: fetch email logs with no reply beyond wait window → filter eligible records → OpenAI generates contextual follow-up → reply to existing Gmail thread → update Email Log and Leads sheet.
Operational Evidence
The centralized email log provides a single source of truth for all outreach activity — draft state, review status, delivery status, timestamps, Gmail thread identifiers, reply state, and follow-up state.

▸Sanitized email log: tracks draft state, review status, delivery status, sent timestamps, Gmail Thread IDs, reply state, and follow-up state. Sensitive email content and contact data redacted.
Engineering Decisions
Structural decisions that shaped the system's reliability, safety, and maintainability.
Configuration Over Hard-Coding
Campaign parameters — target country, search keyword, processing limit, and enabled state — are managed through a structured configuration sheet. Adding a new campaign segment requires only a new row, not workflow edits.
Campaign Control sheet → n8n reads config row → dynamic API parameters per run
Validation Before Persistence
Geographic filtering and contact validation are applied before leads are written to the database. Invalid or out-of-scope leads are discarded early to keep the operational dataset clean.
Post-API geographic filter → contact field validation → conditional branch → write only valid records
Structured Operational State
Each lead record carries explicit pipeline state fields: priority score, outreach status, email log reference, reply state, and processing progress. State is read and written by each workflow stage independently.
Leads sheet columns track discrete workflow states; each stage reads and updates only its own fields
Human Approval Before Outreach
AI-generated drafts are written to a review log and held. A human reviewer sets the approval column before the delivery workflow is permitted to send. AI generation and actual transmission are intentionally decoupled.
Email Log Review column = 'Approved' → delivery workflow queries only approved rows before sending
Duplicate-Risk Reduction Through Row Locking
The delivery workflow immediately marks a row as 'Sending' before dispatching the message. Subsequent trigger evaluations skip rows already in this state, preventing concurrent duplicate sends.
Update row status to 'Sending' → send via Gmail → update to 'Sent'; row locked throughout delivery window
Thread-Aware Reply Tracking
Incoming Gmail replies are matched to the originating outreach thread using Gmail thread identifiers stored during delivery. Reply state is then written back to the lead record and email log.
Gmail Thread ID stored at send time → reply detection matches thread → updates reply state in both sheets
AI-Assisted Personalization With Reviewable Outputs
Website context is extracted via Firecrawl and passed to OpenAI for draft generation. The output is stored for human review before any message is sent, keeping human judgment in the loop at every outbound event.
Firecrawl scrape → context merged into prompt → OpenAI response → draft stored in log, not sent
Reusable Multi-Stage Workflow Architecture
Each pipeline stage — acquisition, drafting, delivery, reply detection, follow-up — is implemented as a separate n8n workflow. Stages communicate through shared sheet state, making individual stages replaceable or testable in isolation.
Independent n8n workflows per stage; shared Google Sheets as the state bus between all stages
What the System Changed
Connected lead discovery, enrichment, and outreach into one structured pipeline
Reduced disconnected manual handoffs between prospecting, messaging, and follow-up steps
Centralized campaign configuration, lead state, and email operational data in one place
Preserved explicit human control before any message leaves the system
Added reply-aware state tracking to the outreach cycle
Created a reusable, stage-isolated multi-workflow outreach architecture
✶ No numerical metrics, ROI figures, or conversion rates are represented. These are qualitative system-level outcomes.
Tech Stack
n8n
Workflow orchestration — all pipeline stages
Outscraper
Lead discovery — business data extraction
Google Sheets
Operational state — campaign config, leads DB, email log
OpenAI
AI personalization — draft generation and follow-up content
Gmail
Delivery channel — send, reply detection, thread continuity
Firecrawl
Web research — structured site content extraction per lead
