退信与无效检测 (Gmail 触发器)
高级
这是一个自动化工作流,包含 26 个节点。主要使用 Code, Cron, Gmail, Merge, Slack 等节点。 使用 Gmail、Google Sheets 和 Slack 自动化邮件退信与无效检测
前置要求
- •Google 账号和 Gmail API 凭证
- •Slack Bot Token 或 Webhook URL
- •Google Sheets API 凭证
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "BwfB2WsAGCX5rTFB",
"meta": {
"instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
"templateCredsSetupCompleted": true
},
"name": "退信与无效检测 (Gmail 触发器)",
"tags": [],
"nodes": [
{
"id": "bff28463-72c1-415a-aac0-8d19808addcf",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
384,
1104
],
"parameters": {},
"typeVersion": 1
},
{
"id": "3b5dabd0-e0ad-4b27-86d3-fc326edc2842",
"name": "解析退信邮箱地址",
"type": "n8n-nodes-base.function",
"position": [
1184,
1120
],
"parameters": {
"functionCode": "// Input: items array (from Gmail node output)\n// Output: one item per failed email address\n\nreturn items\n .map(item => {\n const snippet = item.json.snippet || \"\";\n const match = snippet.match(/wasn't delivered to\\s+([\\w.-]+@[\\w.-]+\\.\\w+)/i);\n if (match) {\n return {\n json: {\n failedEmail: match[1],\n subject: item.json.Subject || \"\",\n id: item.json.id,\n snippet: snippet\n }\n };\n }\n return null;\n })\n .filter(item => item !== null);\n"
},
"typeVersion": 1
},
{
"id": "bde866db-a655-4cb3-bba1-81dbda49e09c",
"name": "获取所有邮箱联系人",
"type": "n8n-nodes-base.googleSheets",
"position": [
736,
1296
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit?usp=drivesdk",
"cachedResultName": "Fraud Email"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s4dP1fNuVZ2gWvs3",
"name": "Google Sheets account"
}
},
"typeVersion": 3
},
{
"id": "ac79fbd2-381e-4de2-b5e2-e7502752978d",
"name": "将状态写回表格",
"type": "n8n-nodes-base.googleSheets",
"position": [
1904,
1232
],
"parameters": {
"options": {},
"fieldsUi": {
"values": [
{
"column": "Status",
"fieldValue": "={{ $json.Status }}"
},
{
"column": "Last Updated",
"fieldValue": "={{ $json[\"Last Updated\"] }}"
}
]
},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit?usp=drivesdk",
"cachedResultName": "Fraud Email"
},
"valueToMatchOn": "={{ $json.Name }}",
"columnToMatchOn": "Name"
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s4dP1fNuVZ2gWvs3",
"name": "Google Sheets account"
}
},
"typeVersion": 3
},
{
"id": "7f7c1971-5591-4f6c-a3dd-06c3e3e20bb6",
"name": "每日晚上7点报告触发器",
"type": "n8n-nodes-base.cron",
"position": [
304,
1904
],
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 19
}
]
}
},
"typeVersion": 1
},
{
"id": "36ffd609-d7c2-461f-82c1-c7303f3e5f46",
"name": "读取更新的表格数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
608,
1904
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-4TaBE0cOTO1iwrrah5y822s8KXrWWkxFmJYiGCfWx4/edit?usp=drivesdk",
"cachedResultName": "Fraud Email"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "s4dP1fNuVZ2gWvs3",
"name": "Google Sheets account"
}
},
"typeVersion": 3
},
{
"id": "4ad00c44-5e60-452a-b4ab-89cc23b38c7c",
"name": "发送 Slack 每日摘要",
"type": "n8n-nodes-base.slack",
"position": [
1120,
1904
],
"parameters": {
"text": "=📢 *Daily Bounce Cleanup Report* \n📧 Invalid Marked: {{$json[\"Invalid emails\"]}} \n📭 No Action Marked: {{$json[\"No activity\"]}} \n✅ Keep your lists healthy 💪\n",
"channel": "#email-cleanup",
"attachments": [],
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "rNqvWj9TfChPVRYY",
"name": "Slack account vivek"
}
},
"typeVersion": 1
},
{
"id": "c3984c6c-4861-46fe-8b6b-68bf842f3fa4",
"name": "获取退信通知",
"type": "n8n-nodes-base.gmail",
"position": [
672,
1120
],
"webhookId": "c4ef7681-fe33-4c55-952d-db9916b6ee6e",
"parameters": {
"filters": {
"sender": "mailer-daemon@googlemail.com"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "RchiXdmY8WaQhOSJ",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "ca28e3bf-d30f-4e54-affc-5b36be6b928e",
"name": "获取最新5封退信",
"type": "n8n-nodes-base.code",
"position": [
880,
1120
],
"parameters": {
"jsCode": "// Get all Gmail messages\nconst emails = items.map(item => item.json);\n\n// Sort by internalDate (descending → newest first)\nemails.sort((a, b) => Number(b.internalDate) - Number(a.internalDate));\n\n// Slice the top 5 messages\nconst latestFive = emails.slice(0, 5);\n\n// Return each of the top 5 as separate items\nreturn latestFive.map(email => ({ json: email }));\n"
},
"typeVersion": 2
},
{
"id": "a7f0f64f-1af0-4ad9-814d-49a1cff65699",
"name": "合并退信与联系人数据",
"type": "n8n-nodes-base.merge",
"position": [
1424,
1232
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "84ff56ce-1a6f-472f-b4ab-bf50705d87f9",
"name": "匹配并更新联系人状态",
"type": "n8n-nodes-base.code",
"position": [
1616,
1232
],
"parameters": {
"jsCode": "// Separate bounce reports and contact rows\nconst failedEmails = items\n .filter(i => i.json.failedEmail)\n .map(i => i.json.failedEmail);\n\nconst contacts = items.filter(i => i.json.Email);\n\n// Current timestamp\nconst now = new Date().toISOString();\n\n// Update contacts based on whether they appear in failedEmails\nconst updatedContacts = contacts.map(item => {\n const email = item.json.Email;\n const isFailed = failedEmails.includes(email);\n\n return {\n json: {\n row_number: item.json.row_number,\n Name: item.json.Name,\n Email: email,\n Status: isFailed ? \"Not Found\" : \"Not Sent\",\n \"Last Updated\": now\n }\n };\n});\n\nreturn updatedContacts;\n"
},
"typeVersion": 2
},
{
"id": "d020cba9-9eaa-406c-9bc6-d6d3c20ba1db",
"name": "计算摘要统计",
"type": "n8n-nodes-base.code",
"position": [
848,
1904
],
"parameters": {
"jsCode": "// Extract all contact rows\nconst contacts = items.map(item => item.json);\n\n// Count based on status\nlet invalidCount = 0;\nlet noActivityCount = 0;\n\nfor (const contact of contacts) {\n const status = (contact.Status || \"\").toLowerCase();\n if (status === \"not found\") invalidCount++;\n if (status === \"not sent\") noActivityCount++;\n}\n\n// Return clean summary as one item\nreturn [\n {\n json: {\n \"Invalid emails\": invalidCount,\n \"No activity\": noActivityCount\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "5ae11ced-5c43-4a24-a8b2-2a49757f7e4e",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
960
],
"parameters": {
"width": 446,
"height": 456,
"content": "## 🎯 主工作流 - 邮箱退信检测"
},
"typeVersion": 1
},
{
"id": "1615d0f0-4afd-4da2-bb0d-9bd41db897cc",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-352,
1728
],
"parameters": {
"width": 446,
"height": 317,
"content": "## 📊 每日报告工作流"
},
"typeVersion": 1
},
{
"id": "d795adbb-b531-4b9c-8e0d-eda50037f4e1",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
224,
768
],
"parameters": {
"width": 237,
"height": 300,
"content": "## 🚀 从这里开始"
},
"typeVersion": 1
},
{
"id": "32e515c9-4c0a-40c9-a97f-e06aea785971",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
736
],
"parameters": {
"width": 237,
"height": 348,
"content": "## 📬 获取退信"
},
"typeVersion": 1
},
{
"id": "5afaf827-064a-4149-a855-61cb71c9d5d3",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
704
],
"parameters": {
"width": 237,
"height": 380,
"content": "## 🔢 限制处理量"
},
"typeVersion": 1
},
{
"id": "fa7f3745-4b40-4b7c-be33-5ebeceb7352b",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1264,
704
],
"parameters": {
"width": 237,
"height": 380,
"content": "## 🔍 提取邮箱地址"
},
"typeVersion": 1
},
{
"id": "1c0510ae-68e7-4c42-ac92-5523fe4b7978",
"name": "便签 7",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
1360
],
"parameters": {
"width": 237,
"height": 412,
"content": "## 📋 获取联系人"
},
"typeVersion": 1
},
{
"id": "62be1676-694b-4328-b126-1849078b9b91",
"name": "便签 8",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
1408
],
"parameters": {
"width": 237,
"height": 284,
"content": "## 🔗 合并数据"
},
"typeVersion": 1
},
{
"id": "bbb6ffaa-74da-47f7-853f-5d1969fa0214",
"name": "便签 9",
"type": "n8n-nodes-base.stickyNote",
"position": [
1664,
1408
],
"parameters": {
"width": 237,
"height": 412,
"content": "## ✅ 更新状态"
},
"typeVersion": 1
},
{
"id": "db166829-b496-43af-a332-79ddf6de2528",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
2176,
1200
],
"parameters": {
"width": 236.93062200956936,
"height": 187.9942396313364,
"content": "## 💾 保存到表格"
},
"typeVersion": 1
},
{
"id": "a89cbaf1-3665-4e51-97a6-29d55123ce1f",
"name": "便签 11",
"type": "n8n-nodes-base.stickyNote",
"position": [
176,
2048
],
"parameters": {
"width": 237,
"height": 300,
"content": "## ⏰ 每日计划"
},
"typeVersion": 1
},
{
"id": "b653e1c7-0247-4d6f-a732-eec9050795ce",
"name": "便签 12",
"type": "n8n-nodes-base.stickyNote",
"position": [
448,
1584
],
"parameters": {
"width": 237,
"height": 300,
"content": "## 📖 读取表格"
},
"typeVersion": 1
},
{
"id": "350dc62c-4f26-4b8d-8914-9821b38b3fb5",
"name": "便签 13",
"type": "n8n-nodes-base.stickyNote",
"position": [
768,
2080
],
"parameters": {
"width": 237,
"height": 332,
"content": "## 🧮 计算统计"
},
"typeVersion": 1
},
{
"id": "f2fd8aa0-3e40-4df0-85fa-3a22e5f019d5",
"name": "便签 14",
"type": "n8n-nodes-base.stickyNote",
"position": [
1312,
1792
],
"parameters": {
"width": 237,
"height": 316,
"content": "## 💬 发送到 Slack"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "1ad9a2ea-ab34-4d93-bc86-e5cc5e4453f3",
"connections": {
"Get Latest 5 Bounces": {
"main": [
[
{
"node": "Parse Bounced Email Addresses",
"type": "main",
"index": 0
}
]
]
},
"Read Updated Sheet Data": {
"main": [
[
{
"node": "Calculate Summary Statistics",
"type": "main",
"index": 0
}
]
]
},
"Daily 7PM Report Trigger": {
"main": [
[
{
"node": "Read Updated Sheet Data",
"type": "main",
"index": 0
}
]
]
},
"Fetch All Email Contacts": {
"main": [
[
{
"node": "Combine Bounce & Contact Data",
"type": "main",
"index": 1
}
]
]
},
"Fetch Bounce Notifications": {
"main": [
[
{
"node": "Get Latest 5 Bounces",
"type": "main",
"index": 0
}
]
]
},
"Calculate Summary Statistics": {
"main": [
[
{
"node": "Send Slack Daily Summary",
"type": "main",
"index": 0
}
]
]
},
"Combine Bounce & Contact Data": {
"main": [
[
{
"node": "Match & Update Contact Status",
"type": "main",
"index": 0
}
]
]
},
"Match & Update Contact Status": {
"main": [
[
{
"node": "Write Status Back to Sheet",
"type": "main",
"index": 0
}
]
]
},
"Parse Bounced Email Addresses": {
"main": [
[
{
"node": "Combine Bounce & Contact Data",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Fetch Bounce Notifications",
"type": "main",
"index": 0
},
{
"node": "Fetch All Email Contacts",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
从 ClickUp 和 Google Sheets 同步 KPI 指标到 Slack 和 Gmail
将 KPI 指标从 ClickUp 和 Google Sheets 同步至 Slack 和 Gmail
Set
Code
Cron
+7
20 节点Rahul Joshi
统一支持团队绩效仪表板(Zendesk & Freshdesk → Google Sheets + Slack + Gmail)
使用Sheets、Slack和Gmail跨Zendesk和Freshdesk跟踪支持绩效指标
If
Code
Cron
+7
24 节点Rahul Joshi
内容创作
API速率限制与认证FAQ测试
使用GPT-4o-mini、Google表格和Slack提醒自动化API常见问题质量测试
If
Set
Code
+7
19 节点Rahul Joshi
文档提取
从 GoHighLevel 自动发送客户续约提醒到 Gmail 和 Slack
从GoHighLevel自动发送客户续约提醒到Gmail、Slack和Google Sheets
If
Code
Gmail
+7
19 节点Rahul Joshi
客户关系管理
自动化 Jira 与 Monday.com 之间的跨项目依赖跟踪
自动化Jira和Monday.com之间的跨项目依赖关系跟踪
If
Code
Cron
+6
21 节点Rahul Joshi
新开发人员入职自动化
使用 GPT-4o 实现员工入职自动化:Jira、Notion 和 Gmail 集成
If
Set
Code
+9
21 节点Rahul Joshi
人力资源
工作流信息
难度等级
高级
节点数量26
分类-
节点类型9
作者
Rahul Joshi
@rahul08Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.
外部链接
在 n8n.io 查看 →
分享此工作流