n8n + OpenAI: Build a Personalized Cold Email Generator
Cold email still works — but only when it doesn't feel cold. The problem is that writing personalized outreach at scale is a grind. You either sacrifice personalization for volume or volume for qualit
Cold email still works — but only when it doesn't feel cold. The problem is that writing personalized outreach at scale is a grind. You either sacrifice personalization for volume or volume for quality. With n8n and OpenAI, you can have both: a workflow that pulls lead data, generates genuinely personalized email copy, and queues it for sending — automatically.
What This Workflow Actually Does
The core idea is simple: feed lead context into GPT, get a tailored email out. But the details matter. A well-built n8n cold email workflow typically does the following:
- Pulls leads from a Google Sheet, Airtable, or CRM like Pipedrive
- Enriches each lead with context — company size, industry, LinkedIn bio, recent news
- Sends that context to the OpenAI API with a structured prompt
- Parses the response into subject line, body, and a personalized opening line
- Writes the draft back to a sheet or pushes it directly to Gmail or Instantly
Each step is a node in n8n. No code required — just logic, connected visually. The result is a pipeline that produces email drafts indistinguishable from ones written manually, but at the pace of an API call.
Building the OpenAI Prompt That Actually Converts
Most people use a generic prompt and wonder why the output sounds robotic. The prompt is the lever. You need to pass enough context that GPT can write something specific, and constrain the output format so you can parse it reliably.
A practical prompt structure looks like this:
- Role: "You are an expert B2B copywriter writing cold emails for [industry]."
- Context: Pass the lead's name, company, role, and one specific detail (e.g., a recent funding round or a job posting).
- Instruction: "Write a 3-sentence cold email. Line 1: a personalized opener referencing the context. Line 2: one concrete benefit. Line 3: a low-friction CTA."
- Output format: Ask for JSON with keys
subject,opener,body,cta— this makes parsing in n8n trivial.
Use the OpenAI node in n8n with the Chat Completions endpoint. Set temperature to 0.7 for variety without going off-script. For lead-specific details, inject them using n8n's expression syntax directly into the prompt string — no extra code needed.
Connecting the Pieces in n8n
Here is a minimal workflow structure that works in production:
- Trigger: Schedule node (run daily) or a webhook from your CRM when a new lead is added
- Read leads: Google Sheets node or HTTP Request to your CRM's API
- Loop: SplitInBatches node to process leads one at a time and respect API rate limits
- Enrich (optional): HTTP Request to a data provider like Apollo, Hunter, or Clay
- Generate email: OpenAI node with your structured prompt and lead data injected
- Parse response: Set node to extract subject, body, and opener from the JSON output
- Output: Write to Google Sheets for review, or push to Gmail/Instantly/Smartlead for sending
The whole thing runs in under 30 seconds per lead. For a list of 200 contacts, you're looking at a few minutes of automated work versus hours of manual writing.
Where This Breaks and How to Fix It
Three failure points come up consistently when people build this themselves:
- OpenAI returns malformed JSON: GPT doesn't always respect format instructions perfectly. Add a Code node to validate and clean the response before passing it downstream. Or use GPT-4 with
response_format: { type: "json_object" }in the API call. - Rate limits from OpenAI or your sending platform: Wrap your loop in a Wait node with a 1–2 second delay between iterations. It adds a few minutes to the run but prevents failed requests from breaking the whole batch.
- Personalization details are missing for some leads: Use an IF node to check whether enrichment data exists before building the prompt. If the context is thin, fall back to a shorter, more generic prompt rather than letting GPT hallucinate details.
These aren't edge cases — they happen on real lists. Build the error paths from day one.
If you want to skip the build-from-scratch phase, ready-made n8n templates give you a working starting point with the node structure, prompt engineering, and error handling already done — so you spend your time on the strategy, not on wiring up nodes.
The combination of n8n's visual workflow builder and OpenAI's language model is genuinely powerful for cold email. The infrastructure is lightweight, the cost per email is fractions of a cent, and the output quality — when the prompt and data are right — is high enough that recipients engage. That's the result worth building toward.

Ja construimos isso pra voce
Nao comece do zero. O Lost Deal - 30-Day Reactivation e um workflow n8n pronto para instalar que faz exatamente isso — em minutos, nao horas.
Instalar por $49 →