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.
| Module | Input | Output | Estimated time |
|---|---|---|---|
| Lead import and cleaning | CSV/Google Sheet | Structured lead list | 5 minutes |
| AI personalized generation | Lead information + OpenAI | Personalized outreach copywriting | 10 minutes |
| Automatic sending queue | Copywriting + recipients | Sent emails + tracking records | 10 minutes |
| CRM writeback | Send results | Update lead status in CRM | 5 minutes |
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)
// Filter 节点条件示例
{
"conditions": {
"email": { "exists": true },
"name": { "exists": true }
}
}提示:免费版 n8n Cloud 支持 5 个工作流和基础节点,完全够跑这个 SDR 系统。如果处理量大,推荐使用 n8n 付费计划 获得更高执行配额。
第 2 步:配置 AI 个性化引擎
这是整个系统的核心。添加 OpenAI 节点,选择 "Create Message" 操作模式。
系统提示词(System Prompt):
你是一个专业的销售开发代表(SDR)。为潜在客户生成个性化的 outreach 邮件。
根据以下信息生成一封自然、不套路化的邮件正文(纯文字,无模板感):
- 客户姓名和职位
- 公司名称和所属行业
- 我们的价值主张:[AI 自动化可以帮他们节省 60% 的人工操作时间]
邮件风格要求:专业但友好,展示你做了功课,不推销感。在 OpenAI 节点的 Messages 字段中,用 n8n 变量引用前一步的线索数据:
来自: {{ $json.name }}
职位: {{ $json.title }}
公司: {{ $json.company }}
行业: {{ $json.industry }}| 配置项 | 建议值 | 说明 |
|---|---|---|
| Model | gpt-4o-mini | 性价比最高,SDR 场景足够 |
| Temperature | 0.7 | 保持创意但稳定 |
| Max Tokens | 500 | 邮件长度适中 |
| System Prompt | 见上方 | 关键:让 AI 理解 SDR 角色 |
创建一个 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。
// 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:n8n、OpenAI、ChatGPT、Claude、DeepSeek、HubSpot、Slack
Reference video/material
Internal link guidance
- Someone has successfully practiced it: 我用 n8n + OpenAI 搭建 AI 内容自动化网站:月入 $4,500 的完整复盘
- Recommended tool: n8n 自动化平台
Related tutorials
AI Coding Agents Complete Guide: Setup, Security, Workflow & Case Studies
If you are researching AI coding agents and want to know which one to use, how to set it up safely, and what real developers are building with them — this hub organizes every tutorial, case study, and comparison we have published. Start with the decision guide below to find the right path for your skill level and goals.
AI Micro SaaS FAQ: 25 Common Questions Answered (2026)
Everything you need to know about building and profiting from AI Micro SaaS products. This FAQ covers idea generation, tech stack choices, pricing strategy, marketing on a $0 budget, legal considerations, and scaling from $100 to $10K MRR. Based on real case studies and data from successful solo builders using Claude Code, Cursor, and other AI coding tools.
Topic hub
AI Agent Tutorials & Workflow Guides
Evergreen how-tos for coding agents, content pipelines, and n8n automation—linked to news context and real earn cases.
Explore AI Agent Tutorials & Workflow Guides →Monetization angle
How can you make money from this trend?
WayToClawEarn focuses on verified earn playbooks—not just news. Start from these cases.
DeepSeek + Claude Code Micro SaaS
Run multiple small products on cheap inference
Claude Code bug bounty
Productize agent skills into security services