Use AI to Build the Business and the Life, You Actually Want. Practical insights on AI, identity, and growth for entrepreneurs who are done playing small. One email a week. No noise.

Home › Playbooks › Automate Cold Email Personalization with AI

Automate Cold Email Personalization with AI

This playbook explains how to build a comprehensive automation workflow in n8n that generates highly customized, multi-line icebreakers for cold email campaigns.

By combining deep website scraping via Apify with advanced data processing, this system can take a simple list of leads and produce personalized pitches that feel as though you’ve meticulously researched each recipient.

When implemented correctly, this type of deep personalization can achieve reply rates of 5–10% on cold email campaigns.

Phase 1: Lead Retrieval and Initial Filtering

Set Up the Workflow Trigger

  • Add a Manual Trigger node to the n8n canvas.
  • This is commonly used when testing the flow.

Retrieve Search URLs

  • Add a Google Sheets node and configure it to Get Rows in Sheet.
  • Connect the flow to your multi-line icebreaker generator Google Sheet.
  • Select the search URLs sheet to retrieve the Apollo search URL used to source leads.
  • Tip: Pin the resulting data to allow faster testing and conserve API usage.

Scrape Leads via Apify

  • Add an HTTP Request node (or Apify scraper module).
  • Send a POST request to the Apify API URL to trigger an actor to scrape the Apollo list URL.
  • The Apify instance gathers lead data: first names, emails, LinkedIn URLs, website URLs, and organization names.

Filter Leads

  • Add a Filter node.
  • Ensure leads continue only if they include both an email address and a website URL.
  • This step removes unusable leads, e.g., reducing 96 items down to around 28.

Phase 2: Deep Website Scraping

Scrape the Homepage HTML

  • Add an HTTP Request node to process the remaining leads.
  • Input the website URL from the lead data.
  • Configure redirects: enable follow redirects with a high count (e.g., 21).
  • Under Settings, set error handling to continue using error output.

Extract Website Links

  • Connect the success output to an HTML Extractor node.
  • Configuration:
  • Key: links
  • CSS Selector: a
  • Return Value: Attribute
  • Attribute: href
  • Return as: Array

Clean and Format Data Fields

  • Add an Edit Fields node.
  • Retain essential information (First Name, Last Name, Website, Headline, Location, Phone Number) alongside extracted links.

Phase 3: Processing Links in a Loop

Initiate the Processing Loop

  • Add a Split in Batches or Loop Over Items node to handle each lead sequentially.

Split Out Links

  • Inside the loop, add a Split Out node.
  • This separates the array of links so each becomes an item.

Filter for Relative Links

  • Add a Filter node.
  • Ensure the link string starts with / to isolate relative URLs (often important sub-pages).

Remove Duplicates

  • Add a Remove Duplicates node to clean repeated items.

Scrape Individual Pages

  • Add another HTTP Request node.
  • Concatenate the base website URL with the relative link.

Convert HTML to Markdown

  • Add an HTML to Markdown node.
  • Conversion reduces token costs before sending text to the AI.
  • Optional: Cap data length (e.g., 5,000 characters) to avoid timeouts.

Summarize Individual Pages (AI Step 1)

  • Add an OpenAI node.
  • Model: GPT-4.
  • System Prompt: “You’re a helpful intelligent website scraping assistant.”
  • User Prompt: Summarize each page in two paragraphs, Spartan tone, return JSON { "abstract": "..." }.
  • If empty, return “no content”.

Phase 4: Aggregation and Final AI Generation

Aggregate Summaries

  • Add an Aggregate node.
  • Combine all abstract fields for a specific lead into one array.

Generate Multi-Line Icebreaker (AI Step 2)

  • Add a second OpenAI node.
  • Input: aggregated website summaries.
  • Prompt strategy: provide a template opener (e.g., “Hey [name], love [thing]…”).
  • Rules:
  • Use a Spartan Lonic tone.
  • Highlight small, non-obvious details.
  • Shorten company/location names.
  • Use few-shot prompting with examples.

Complete the Loop

  • Connect the output of the AI generation node back to the loop input.

Update the Google Sheet

  • Add a final Google Sheets node outside the loop, set to Append Row.
  • Select the multi-line icebreaker generator document and the leads sheet.
  • Map original lead fields and the new multi-line icebreaker to the corresponding columns.

Share this post: