Albin Hot

Albin HotVerified

Learn to Rank #1 in Google

@niblahistaken

Cold Email Automation in N8N – Step-by-Step with FREE Template

Why N8N is Perfect for Cold Email Automation

N8N is a powerful, open-source workflow automation tool that's perfect for cold email campaigns. Unlike expensive tools like Zapier or HubSpot, N8N gives you:

  • Complete control over your email automation
  • Advanced JavaScript customization capabilities
  • Cost-effective scaling for high-volume campaigns
  • Integration with Google Sheets, Gmail, and SMTP servers
  • Built-in delay and randomization features to avoid spam filters

What You'll Learn in This Tutorial

This comprehensive guide covers everything you need to build a professional cold email automation system:

  • ✅ How to pull leads and email templates directly from Google Sheets
  • ✅ How to use JavaScript to randomize and rotate your email content
  • ✅ How to personalize and send emails using Gmail or an SMTP server
  • ✅ How to log each email's send status and timestamp back into Sheets
  • ✅ How to reduce spam risk by adding delays between email sends
  • ✅ How to loop your workflow to send emails in bulk automatically

Essential JavaScript Code Snippets

Here are the key JavaScript snippets used in this automation workflow:

1. Pick a Random Template JavaScript

This script randomly selects an email template from your Google Sheets to avoid sending identical emails:

Random Template Picker
// Get templates from previous node
const templates = items.map(item => item.json);

// Check if templates exist
if (!templates || templates.length === 0) {
  throw new Error('No templates found');
}

// Pick a random template
const index = Math.floor(Math.random() * templates.length);
const template = templates[index];

// Convert body to HTML
const bodyHtml = template.Body.replace(/\n/g, '<br>');

// Return in n8n-compatible format
return [
  {
    json: {
      subject: template.Subject,
      body: bodyHtml
    }
  }
];

2. Personalize the Email

This snippet merges lead data (like name and company) into your email template:

Email Personalization
// Get lead and template data
const lead = items[0].json;
const template = items[1].json;

// Replace placeholders
let personalizedBody = template.body.replace(/{{firstName}}/g, lead.FirstName);
personalizedBody = personalizedBody.replace(/{{companyName}}/g, lead.Company);

// Return personalized content
return [
  {
    json: {
      ...lead,
      subject: template.subject,
      body: personalizedBody
    }
  }
];

3. Log Send Status to Google Sheets

After sending an email, this script updates your Google Sheet with the send status and a timestamp:

Send Status Logging
// Get the lead data
const lead = items[0].json;

// Get current timestamp
const now = new Date();
const timestamp = now.toISOString();

// Prepare data for Google Sheets
return [
  {
    json: {
      'A': lead.Email, // Assuming email is in column A
      'D': 'Sent', // Assuming status is in column D
      'E': timestamp // Assuming timestamp is in column E
    }
  }
];

Expected Results

By implementing this automated system, you can expect:

  • Achieve 15-25% open rates with proper targeting
  • Get 2-5% response rates on well-crafted campaigns
  • Save 10+ hours per week on manual email tasks
  • Scale your outreach without increasing costs

Get the FREE Template

Download the complete N8N workflow template and Google Sheets setup to get started immediately. The template includes all the JavaScript code, proper node configurations, and a sample lead database structure.

Albin Hot

About the Author

Albin Hot

I am a 23 year old entrepreneur with multiple successful online ecommerce stores built through SEO. I am now helping others achieve the same success through my digital marketing expertise and proven strategies.