WayToClawEarn
Intermediate30 min readMay 13, 2026

How to use n8n + OpenAI to build an AI sales development representative system: 30 minutes of automated customer mining

Build a complete SDR Agent from scratch for automated lead mining, personalized contact, and CRM write-back

Intermediate · 30 min · May 13, 2026

Tutorial Objectives

In 30 minutes, build an automated AI sales development representative (SDR) system with n8n + OpenAI. The system automatically mines leads from public data sources, uses AI to generate personalized outreach emails, and writes the results into a CRM.

What will you build?

  • Automated Lead Miner: Automatically get a list of leads from CSV/Public API
  • AI Personalization Engine: Use OpenAI to generate customized outreach content for each lead
  • Automated sending pipeline: Automatically send via email API and track opens/replies
  • CRM Writeback Bridge: Automatically log interaction results to HubSpot/Salesforce

Preparation list

  • n8n account (Cloud free version is available, it is recommended to use n8n Cloud to reduce setup time)
  • OpenAI API Key (platform.openai.com registered to obtain)
  • A CSV file or Google Sheet with lead information
  • Gmail/SendGrid account is used to send emails (optional, you can also send manually)

Overall architecture

This tutorial will build a complete SDR automation pipeline, divided into 4 core modules.

ModuleInputOutputEstimated time
Lead import and cleaningCSV/Google SheetStructured lead list5 minutes
AI personalized generationLead information + OpenAIPersonalized outreach copywriting10 minutes
Automatic sending queueCopywriting + recipientsSent emails + tracking records10 minutes
CRM writebackSend resultsUpdate lead status in CRM5 minutes

Text example — n8n workflow builder interface

Step 1: Build the lead import module

Start by creating a new workflow in n8n. Add a Google Sheets node (or Read CSV Files node) as the data source.

Configuration points:

  • Data columns are recommended to include: name, company, title, linkedin_url, email, industry
  • If there is no existing data, n8n's built-in HTTP Request node can obtain enterprise leads from Apollo API or Hunter.io
  • Add a Filter node to filter invalid data (empty emails, incomplete records)
json
// Filter 节点条件示例
{
  "conditions": {
    "email": { "exists": true },
    "name": { "exists": true }
  }
}

提示:免费版 n8n Cloud 支持 5 个工作流和基础节点,完全够跑这个 SDR 系统。如果处理量大,推荐使用 n8n 付费计划 获得更高执行配额。

第 2 步:配置 AI 个性化引擎

这是整个系统的核心。添加 OpenAI 节点,选择 "Create Message" 操作模式。

系统提示词(System Prompt):

code
你是一个专业的销售开发代表(SDR)。为潜在客户生成个性化的 outreach 邮件。
根据以下信息生成一封自然、不套路化的邮件正文(纯文字,无模板感):
- 客户姓名和职位
- 公司名称和所属行业
- 我们的价值主张:[AI 自动化可以帮他们节省 60% 的人工操作时间]

邮件风格要求:专业但友好,展示你做了功课,不推销感。

在 OpenAI 节点的 Messages 字段中,用 n8n 变量引用前一步的线索数据:

code
来自: {{ $json.name }}
职位: {{ $json.title }}
公司: {{ $json.company }}
行业: {{ $json.industry }}
配置项建议值说明
Modelgpt-4o-mini性价比最高,SDR 场景足够
Temperature0.7保持创意但稳定
Max Tokens500邮件长度适中
System Prompt见上方关键:让 AI 理解 SDR 角色

Text example — OpenAI node configuration in n8n

创建一个 Switch 节点来分流 API 调用失败时的逻辑:成功 → 发送步骤;失败 → 存入错误队列并标记。

第 3 步:搭建自动化发送与追踪管道

添加 Gmail 节点(或 SendGrid 节点),将 AI 生成的邮件内容自动发送。

配置 Gmail 节点:

  • OAuth2 认证(先在 n8n 中配置 Google 凭据)
  • 收件人:{{ $json.email }}
  • 主题:AI automation suggestions for {{ $json.company }}(用变量保持个性化)
  • 正文:{{ $json.generated_comment }}(AI 生成内容)

添加 n8n 子工作流 节点来处理追踪:

  • 发送后 24 小时检查是否被打开
  • 如果打开但未回复,触发 AI 生成 follow-up 邮件
  • 如果已回复,标记为 "热线索" 并发送 Slack 通知

推荐工具:使用 n8n Cloud 可以一键部署这个完整工作流,无需自己管理服务器。如果偏好本地部署,n8n 也完全开源。

第 4 步:CRM 回写与数据分析

添加 HubSpot 节点(或 Salesforce 节点)将互动结果写回 CRM。

json
// HubSpot Update Contact 节点配置
{
  "resource": "contact",
  "operation": "update",
  "contactId": "{{ $json.hubspot_id }}",
  "properties": {
    "hs_lead_status": "contacted",
    "last_contacted_date": "{{ $now.toISOString() }}",
    "outreach_message_snippet": "{{ $json.generated_comment.slice(0, 200) }}"
  }
}

最后添加一个 Google Sheets 节点,记录每次 outreach 的结果(已发送、已打开、已回复),形成完整的销售分析看板。

常见问题排查(FAQ)

Q1:OpenAI API 调用超时怎么办?

在 OpenAI 节点的 Settings 中设置 Retry on Fail = 3 次,Timeout = 30 秒。如果仍超时,检查 API Key 余额或换用 gpt-4o-mini(更快更便宜)。

Q2:n8n Cloud 免费版够用吗?

够用。免费版支持 5 个工作流和 2500 次/月执行。对于个人 SDR 系统(每周处理 100-200 条线索)完全足够。量大了升级付费计划即可。

Q3:邮件被标记为垃圾邮件怎么办?

确保配置 SPF/DKIM 记录(Gmail 默认配置且发送量不大时极少被标记)。另外,AI prompt 中强调 "不做推销感,提供真实价值" 能显著降低被标记概率。

SEO+GEO:FAQ 结构满足 GEO 提取偏好,同时覆盖长尾搜索词

工具词条(触发工具悬浮卡)

正文中自然出现的工具名,平台侧会匹配已维护 tools 库生成 hover-card:n8nOpenAIChatGPTClaudeDeepSeekHubSpotSlack

Reference video/material

Internal link guidance

Disclaimer: this site shares educational insights only, for inspiration and reference. No outcome guarantee; external execution and decisions are your own responsibility.

Related tutorials