AI-powered cold email personalization at scale
An n8n system that writes personalized subject lines, icebreakers and PS lines.
Tools featured in this playbook
This article was originally posted on YouTube
Personalization is one of the most important parts of a cold email campaign. A personalized email gets opened and read more, because the lead thinks you did research and wrote it yourself instead of blasting thousands of people. Here is the system I built in n8n to generate three things for every lead: a personalized subject line, an icebreaker and a PS.
How it works
Pull leads from Google Sheets (scraped earlier from Apollo or Sales Navigator).
Scrape the company website and convert it to markdown, a text format LLMs read more easily.
An AI agent writes a one or two sentence summary of what the company does.
Scrape the lead's LinkedIn profile with Apify, a marketplace of community-built scrapers.
An AI agent summarizes the profile: about section, headline, experience, skills.
A third AI agent uses both summaries to write the subject line, icebreaker and PS.
Write everything back to Google Sheets, then import it into Instantly.
The spreadsheet
You only need three input columns: full name, company website and LinkedIn URL. Scrapers often return tons of columns, but this is all you need. Then add output columns:
LinkedIn summary and website summary (not strictly needed, but useful to check what the agent came up with)
Personalized icebreaker, personalized subject line, personalized PS and industry (these become variables in Instantly)
Step 1: pull the leads
Manual trigger for now.
Google Sheets, get rows. On n8n Cloud you can sign in with Google in a pop-up. Self-hosted, you need a client ID and secret from Google Cloud.
Add a filter: only rows where the icebreaker is empty. That way you can run a thousand leads, tweak the prompt, and run the next thousand.
Add a Limit of 1 while you build, so you don't burn Apify and OpenAI credits testing on every row. Turn it off at the end.
Loop over items with a batch size of 1, to process each row one by one.
Step 2: scrape and summarize the website
HTTP request (GET) to the company website from the loop. You get the raw HTML.
Code node to strip unneeded tags and convert to markdown. I had Claude write the code. It outputs markdown and an even cleaner text version.
In the HTTP node settings, set On error to "continue using error output". Some servers block simple requests, which is normal. On the error route, add a Set node with a variable saying "website information not available". That's fine, because we still have LinkedIn.
Merge node, so the flow continues with whichever route ran.
AI agent with a system prompt: a website summarizer that receives markdown content and writes a 3 to 5 sentence summary, returned as JSON with a
summaryfield. The user message is the website content from the merge node.Chat model: OpenAI, GPT-4.1 mini works well. Get an API key from the OpenAI platform and make sure you have money in the account.
Turn on Require specific output format and add a Structured output parser with the same
summarystructure. You get one clean variable back.
Step 3: scrape LinkedIn with Apify
Create an Apify account (you get $5 to test). Use the bulk LinkedIn profile scraper. Make sure it's the same one, because the API call is different for every scraper ("actor").
The catch: when you run an actor through the API, it says "success" right away without waiting for the data. So you need three calls:
Run actor (POST). Paste the endpoint URL without the token part. For auth, use a generic Header Auth credential: name
Authorization, valueBearerfollowed by a space and your Apify personal token (from Settings, API and integrations). Send the JSON body with the profile scraper mode and the lead's LinkedIn URL. Map the URL from the loop node, not from the get rows node, or it loops over the first row again.Get last run (GET). Put the run's
actIdinto the URL. It returns a status: running or succeeded.If the status equals
SUCCEEDED(all caps), continue. If not, Wait 5 seconds and check the status again.Get last run dataset items (GET), again with the
actId. This returns everything the scraper found.
The result is a lot of raw data: photo, about (sometimes null), headline, name, experience and more.
Step 4: summarize the profile
Add a Limit so only one item goes through.
AI agent with a LinkedIn summarizer system prompt and a JSON output format.
In the user message I added conditionals so missing fields show "null" instead of "undefined" and an error. Experience, skills and certifications come as big objects with company IDs, logos and URLs we don't need, so I had Claude write code to extract them cleanly.
OpenAI GPT-4.1 with a structured output parser.
Step 5: write the personalization
The last agent gets the lead's name, the LinkedIn summary and the website summary. Its system prompt asks for four outputs, with example templates for each:
Subject line
Icebreaker
PS line
Industry (so I can customize my copy)
Tweak this prompt to your needs and your ICP. I was pretending to be a software development company. One result: subject "Do you need support with software development at Leech Painting?", icebreaker "Hey Chris, I know you're a leading painting company that focuses on quality and customer care", and PS "Even if we just trade notes on what's working for you, I'm happy to chat."
Step 6: write it back and close the loop
Google Sheets, update row, matching on the row number from the loop, so it always lands on the right row.
Map the LinkedIn summary, website summary, subject line, icebreaker, PS and industry.
Connect this node back to the loop.
On the loop's done branch, add an action like an email saying "icebreakers are done", so you know when to import.
This takes a while. You can process in bigger batches, but it still takes time, so leave long lists running overnight.
Step 7: import into Instantly
Download the sheet as a CSV.
In Instantly, open or create a campaign, add leads and upload the CSV.
Map each personalization column as a custom variable.
In your email, insert the variables (the names match your column names): the icebreaker in the body, the personalized subject line as the subject, plus the PS and industry. Preview with a lead to check.
This makes you stand out from all the other campaigns and newsletters these businesses get, and it improves both your open rates and your reply rates.
Comments
Login to leave a comment