我的工作流
中级
这是一个Sales领域的自动化工作流,包含 14 个节点。主要使用 If, Code, Gmail, GoogleSheets, SplitInBatches 等节点。 从 Google Sheets 验证并创建 LEDGERS 联系人,含错误处理
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "LWUeLMrYSdCmTIl2",
"meta": {
"instanceId": "6e890b37c7899c1c5d9425c983d97e769b3d90c5d9b075bce9d26cb690e7bc84",
"templateCredsSetupCompleted": true
},
"name": "我的工作流",
"tags": [],
"nodes": [
{
"id": "5286306a-9e2c-4e3c-9f3c-9d4ef7820c0c",
"name": "Google Sheets触发器",
"type": "n8n-nodes-base.googleSheetsTrigger",
"position": [
0,
0
],
"parameters": {
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1920008147,
"cachedResultUrl": "",
"cachedResultName": ""
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1m4lbSUudsxNI-thsPBZ1sjMU2yWLSQf0MrURDjBwIlg",
"cachedResultUrl": "",
"cachedResultName": ""
}
},
"credentials": {
"googleSheetsTriggerOAuth2Api": {
"id": "FZ0xD5zZdVdDTlTQ",
"name": "Google Sheets Trigger account"
}
},
"typeVersion": 1
},
{
"id": "40bd5635-03d9-40fa-9f14-c8a724838c7f",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
900,
-120
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "ff50f240-ed69-4561-9831-a08fca231788",
"name": "替换我",
"type": "n8n-nodes-base.noOp",
"position": [
920,
140
],
"parameters": {},
"typeVersion": 1
},
{
"id": "dd49af1e-0bc6-4667-a59a-ff43c2adfc84",
"name": "LEDGERS",
"type": "@ledgers/n8n-nodes-ledgers-cloud.ledgers",
"position": [
1340,
-140
],
"parameters": {
"contactName": "={{ $json['Name'] }}",
"additionalFields": {
"email": "={{ $json['Email'] }}",
"mobile": "={{ $json['Mobile'] }}"
}
},
"credentials": {
"ledgersApi": {
"id": "dzjYO9CwOEVyPPFt",
"name": "LEDGERS account"
}
},
"typeVersion": 1
},
{
"id": "08263687-a6f4-4008-95ef-b625119d475d",
"name": "联系人姓名错误邮件触发器",
"type": "n8n-nodes-base.gmail",
"position": [
0,
220
],
"webhookId": "71b4d908-a807-4350-a1f2-459e3d547e34",
"parameters": {
"sendTo": "",
"message": "=<p>Contact Name is Missing<br>\nrow no: {{ $json['row_number'] }}",
"options": {},
"subject": "Contact Creation Failure"
},
"credentials": {
"gmailOAuth2": {
"id": "7dz2LNMSfjls1cZV",
"name": "Gmail account"
}
},
"notesInFlow": false,
"typeVersion": 2.1
},
{
"id": "8d02c452-50d4-4626-ac4e-38db7796e15c",
"name": "联系人姓名验证",
"type": "n8n-nodes-base.if",
"position": [
220,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2af93c46-69d5-468c-a73c-ebf9ee39d28b",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json['Name'] }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f5d57159-4ecc-422f-a7c2-74c96c921d6a",
"name": "邮箱和手机格式检查器",
"type": "n8n-nodes-base.code",
"position": [
440,
-100
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const email = String($json.Email || '');\nconst regex_email = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nconst mobile = String($json.Mobile || '');\nconst regex_mobile = /^(\\+\\d{1,3}[- ]?)?\\d{10}$/;\n\nlet validEmail = false;\n\nif (!email) {\n validEmail = true; // Treat empty as valid\n} else if (regex_email.test(email)) {\n validEmail = true; // Matches regex\n} else {\n validEmail = false; // Invalid format\n}\n\nlet validMobile = false;\n\nif (!mobile) {\n validMobile = true; // Treat empty as valid\n} else if (regex_mobile.test(mobile)) {\n validMobile = true; // Matches regex\n} else {\n validMobile = false; // Invalid format\n}\n\nreturn {\n json: {\n ...$json,\n validEmail: validEmail,\n validMobile:validMobile\n }\n};"
},
"notesInFlow": false,
"typeVersion": 2
},
{
"id": "51a32d91-3d6a-4a3d-922d-28a681579b02",
"name": "邮箱和手机验证器",
"type": "n8n-nodes-base.if",
"position": [
660,
-100
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c3ce425a-a354-4aad-8edd-3b483c135f8b",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json[validEmail] }}",
"rightValue": ""
},
{
"id": "5728ac2b-d0c0-47a8-963e-5db64fe81429",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json[validMobile] }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "b7d48ba7-6b06-495d-be50-ecc6bf2ef0fb",
"name": "邮箱/手机错误邮件触发器",
"type": "n8n-nodes-base.gmail",
"position": [
440,
120
],
"webhookId": "cc4364f6-d059-4db5-924d-4e3d7396a1ac",
"parameters": {
"sendTo": "",
"message": "=<p>Enter Valid Email/Mobile for contact: <b>{{ $json['Name'] }}</b></p>",
"options": {},
"subject": "Contact Creation Failure"
},
"credentials": {
"gmailOAuth2": {
"id": "Erw1NUA8FEIvD1Ve",
"name": "Gmail account"
}
},
"notesInFlow": true,
"typeVersion": 2.1
},
{
"id": "188e5335-f3cf-4044-bd7a-804c393e53df",
"name": "手机格式化器",
"type": "n8n-nodes-base.code",
"position": [
1120,
-140
],
"parameters": {
"jsCode": "const mobileRaw = String($json.Mobile || '').trim();\n\nlet mobile_country_code = '';\nlet mobile = '';\n\nif (mobileRaw) {\n if (mobileRaw.includes('-')) {\n // Split by -\n const parts = mobileRaw.split('-').map(p => p.trim());\n\n if (parts.length >= 2) {\n mobile_country_code = parts[0];\n mobile = parts.slice(1).join(' ');\n\n // Ensure country code starts with +\n if (!mobile_country_code.startsWith('+')) {\n mobile_country_code = '+' + mobile_country_code;\n }\n }\n } else {\n // No dash, treat as mobile\n mobile = mobileRaw;\n }\n}\n\nreturn {\n json: {\n mobile_country_code,\n mobile\n }\n};"
},
"typeVersion": 2
},
{
"id": "9a91c0ae-dddb-4a56-b956-50c357c1a279",
"name": "联系人创建失败邮件触发器",
"type": "n8n-nodes-base.gmail",
"position": [
1160,
120
],
"webhookId": "85074ac3-6c15-4eea-a9a2-4922f8dc44d2",
"parameters": {
"sendTo": "",
"message": "=Error while creating a contact from the row {{ $json['row_number'] }}\nError: {{ $json['errorMessage'] }}",
"options": {},
"subject": "Contact Creation Failure",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "Erw1NUA8FEIvD1Ve",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "319837cb-0799-4b3b-a528-80ede79b2a90",
"name": "联系人创建验证器",
"type": "n8n-nodes-base.if",
"position": [
1560,
-140
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2da856b9-b6ec-4630-b985-3c6c30a06b76",
"operator": {
"type": "string",
"operation": "notExists",
"singleValue": true
},
"leftValue": "={{ $json['errorCode'] }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "9fd8b8c5-d9bb-4cf6-a38f-7dc9e5ff366b",
"name": "获取创建时间",
"type": "n8n-nodes-base.code",
"position": [
1780,
-160
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const date = new Date();\nconst formatted = date.getDate().toString().padStart(2, '0') + '-' +\n (date.getMonth() + 1).toString().padStart(2, '0') + '-' +\n date.getFullYear() + ' ' +\n date.getHours().toString().padStart(2, '0') + ':' +\n date.getMinutes().toString().padStart(2, '0') + ':' +\n date.getSeconds().toString().padStart(2, '0');\n\nreturn {\n json: {\n ...$json,\n created_at: formatted\n }\n};\n"
},
"typeVersion": 2
},
{
"id": "87d9c064-ade5-451a-9290-8acfc62f123c",
"name": "更新表格联系人创建",
"type": "n8n-nodes-base.googleSheets",
"position": [
1800,
120
],
"parameters": {
"columns": {
"value": {
"Time": "={{ $json['created_at'] }}",
"Contact ID": "={{ $json['contact_id'] }}"
},
"schema": [
{
"id": "Time",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Time",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Contact ID",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Contact ID",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Contact ID"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "",
"cachedResultName": ""
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1b1bxz-j9tgUtsl-_1kkoEs30WyF5r3xQ2fd49JmHTwo",
"cachedResultUrl": "",
"cachedResultName": ""
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "NG69I8s31Hkxt7bW",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "d3b1397a-d068-4fe1-95af-6777351d3cbf",
"connections": {
"LEDGERS": {
"main": [
[
{
"node": "Contact Creation Validator",
"type": "main",
"index": 0
}
]
]
},
"Replace Me": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Mobile Formatter",
"type": "main",
"index": 0
}
],
[
{
"node": "Replace Me",
"type": "main",
"index": 0
}
]
]
},
"Get Created Time": {
"main": [
[
{
"node": "Update Sheet Contact Creation",
"type": "main",
"index": 0
}
]
]
},
"Mobile Formatter": {
"main": [
[
{
"node": "LEDGERS",
"type": "main",
"index": 0
}
]
]
},
"Google Sheets Trigger": {
"main": [
[
{
"node": "Contact Name Validation",
"type": "main",
"index": 0
}
]
]
},
"Contact Name Validation": {
"main": [
[
{
"node": "Email & Mobile Format Checker",
"type": "main",
"index": 0
}
],
[
{
"node": "Contact Name Error Mail Trigger",
"type": "main",
"index": 0
}
]
]
},
"Email & Mobile Validator": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
],
[
{
"node": "Email/Mobile Error Mail Trigger",
"type": "main",
"index": 0
}
]
]
},
"Contact Creation Validator": {
"main": [
[
{
"node": "Get Created Time",
"type": "main",
"index": 0
}
],
[
{
"node": "Contact Creation Failure Mail Trigger",
"type": "main",
"index": 0
}
]
]
},
"Email & Mobile Format Checker": {
"main": [
[
{
"node": "Email & Mobile Validator",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 销售
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
LEDGERS - 使用AI提示添加联系人
从非结构化数据解析创建LEDGERS联系人 - 使用GPT-4o
If
Gmail
Split In Batches
+7
13 节点LEDGERS
AI 摘要总结
LinkedIn自动连接与销售个性化消息
LinkedIn自动连接与销售个性化消息
If
Set
Wait
+12
32 节点Vansh Arora
销售
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
使用AI(GPT-4o)自动化数字产品和SaaS销售
使用AI(GPT-4o)自动化数字产品和SaaS销售
If
Code
Wait
+14
34 节点Badr
销售
AI个性化多产品邮件营销
基于SMTP轮换的AI个性化多产品邮件营销(GPT-4o/o3-mini)
If
Code
Wait
+16
41 节点Badr
销售
基于AI的潜在客户信息增强(Bright Data MCP和Google Sheets)
基于AI的潜在客户信息增强:使用Bright Data MCP和Google Sheets
If
Set
Wait
+19
51 节点Cyril Nicko Gaspar
销售
工作流信息
难度等级
中级
节点数量14
分类1
节点类型8
作者
LEDGERS
@ledgersCompletely integrated suite of cloud-based tools to help you with invoicing, payments, accounting, inventory management, payroll, GST compliance and more.
外部链接
在 n8n.io 查看 →
分享此工作流