从 Notion 同步联系人到 Google 联系人并添加分组标签
高级
这是一个CRM领域的自动化工作流,包含 20 个节点。主要使用 If, Set, Code, Notion, HttpRequest 等节点。 自动将 Notion 联系人同步到 Google 联系人并添加分组标签
前置要求
- •Notion API Key
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "h7YubkTUmnZrsMQs",
"meta": {},
"name": "从 Notion 同步联系人到 Google 联系人并添加分组标签",
"tags": [],
"nodes": [
{
"id": "9884a0d6-5969-4e36-9d1e-e9026cfd2fae",
"name": "从 Notion 获取所有联系人",
"type": "n8n-nodes-base.notion",
"position": [
260,
240
],
"parameters": {
"options": {},
"resource": "databasePage",
"operation": "getAll",
"returnAll": true,
"databaseId": {
"__rl": true,
"mode": "id",
"value": "Enter your Notion database ID here."
}
},
"credentials": {},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "14397583-f0e6-4bc4-9bf1-ac87f80e701a",
"name": "查找匹配标签",
"type": "n8n-nodes-base.code",
"position": [
1400,
240
],
"parameters": {
"jsCode": "// Get raw label from Edit Fields\nconst rawLabel = $('Loop Over Contacts').first().json.label || '';\nconsole.log(\"rawLabel:\", rawLabel);\n\n// Parse if it’s a stringified array, otherwise treat as array or single value\nlet labelNames;\nif (typeof rawLabel === 'string') {\n try {\n labelNames = JSON.parse(rawLabel); // Convert \"['Gelatin 180-200']\" to [\"Gelatin 180-200\"]\n } catch (e) {\n labelNames = [rawLabel]; // If not valid JSON, treat as single string\n }\n} else if (Array.isArray(rawLabel)) {\n labelNames = rawLabel; // Already an array\n} else {\n labelNames = rawLabel ? [rawLabel] : []; // Fallback\n}\n\nconst contactGroups = $input.first().json.contactGroups || [];\n\nconsole.log(\"labelNames (parsed):\", labelNames);\nconsole.log(\"contactGroups:\", contactGroups);\n\n// Match labels and extract resourceName\nconst matchedLabels = labelNames.map(label => {\n const group = contactGroups.find(g => \n g.name.trim().toLowerCase() === label.trim().toLowerCase() && \n g.groupType === \"USER_CONTACT_GROUP\"\n );\n console.log(`Searching for: \"${label}\", Found:`, group);\n return {\n name: label,\n resourceName: group ? [group.resourceName] : null // Wrap resourceName in an array\n };\n});\n\nconsole.log(\"matchedLabels:\", matchedLabels);\n\nreturn matchedLabels.map(label => ({\n json: {\n name: label.name,\n resourceName: label.resourceName // Now an array like [\"contactGroups/40cf29798a92c131\"]\n }\n}));"
},
"executeOnce": true,
"typeVersion": 2
},
{
"id": "bc13d96d-951e-4d7a-90ed-af96617647ef",
"name": "添加联系人到 Google 联系人",
"type": "n8n-nodes-base.googleContacts",
"position": [
1880,
240
],
"parameters": {
"givenName": "={{ $('Loop Over Contacts').item.json.firstName }}",
"additionalFields": {
"group": "={{ $json.resourceName }}",
"phoneUi": {
"phoneValues": [
{
"type": "home",
"value": "={{ $('Loop Over Contacts').item.json.phone }}"
}
]
}
}
},
"credentials": {},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "d61f9032-9982-4aaf-ab68-c827c345c14d",
"name": "工作流概述",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
-540
],
"parameters": {
"width": 1600,
"height": 520,
"content": "# 将 Notion 联系人同步到 Google 联系人并添加分组标签"
},
"typeVersion": 1
},
{
"id": "1c52ad45-98ff-4f32-b58e-81dfe4eda13d",
"name": "触发器说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
20
],
"parameters": {
"color": 6,
"width": 260,
"height": 520,
"content": "当指定 Notion 数据库中添加新联系人或更新现有联系人时触发工作流。"
},
"typeVersion": 1
},
{
"id": "61818fe5-608c-4410-b8fe-f76a203b0123",
"name": "字段映射指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
440,
20
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "将 Notion 字段(姓名、电话、标签、添加状态)映射到变量以供进一步处理。在此处自定义以添加更多字段,如电子邮件。"
},
"typeVersion": 1
},
{
"id": "12fb9b67-4b5a-40b0-90f1-f7e896cd47d9",
"name": "标签匹配指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1340,
20
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "将 Notion 标签与现有 Google 联系人分组匹配,从 Notion 的 property_buy 字段解析标签。"
},
"typeVersion": 1
},
{
"id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"name": "已同步检查指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
920,
20
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "使用 Notion 中的“已添加”字段检查联系人是否已同步到 Google 联系人。"
},
"typeVersion": 1
},
{
"id": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
"name": "分组存在性检查指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1580,
20
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "验证指定分组标签是否存在于 Google 联系人中。如果不存在,则创建新分组。"
},
"typeVersion": 1
},
{
"id": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
"name": "创建分组指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1580,
-160
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "如果指定标签不存在,则在 Google 联系人中创建新分组。"
},
"typeVersion": 1
},
{
"id": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
"name": "添加联系人指南",
"type": "n8n-nodes-base.stickyNote",
"position": [
1820,
20
],
"parameters": {
"color": 6,
"width": 220,
"height": 400,
"content": "将联系人添加到 Google 联系人,包含指定姓名、电话和分组标签。"
},
"typeVersion": 1
},
{
"id": "566b7be5-6090-48eb-acb2-71c0844c240b",
"name": "映射 Notion 联系人字段",
"type": "n8n-nodes-base.set",
"position": [
500,
240
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "cf7632d2-9983-4c09-8021-7043b8606c48",
"name": "firstName",
"type": "string",
"value": "={{ $json.name }}"
},
{
"id": "bc1f218c-bd1b-4b07-b812-1569f483a838",
"name": "label",
"type": "string",
"value": "={{ $json.property_buy }}"
},
{
"id": "d62010cd-2768-40a4-9279-c4742575a7bd",
"name": "phone",
"type": "string",
"value": "={{ $json.property_phone }}"
},
{
"id": "71fe5268-8798-4641-9395-1c2295c83ae0",
"name": "Already Added",
"type": "string",
"value": "={{ $json.property_added_to_contacts }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "8f91fe10-353f-4a03-8ddf-18c8958188aa",
"name": "遍历联系人",
"type": "n8n-nodes-base.splitInBatches",
"position": [
760,
240
],
"parameters": {
"options": {
"reset": false
}
},
"typeVersion": 3
},
{
"id": "2d832694-f231-4201-8432-9d032e000d7f",
"name": "获取 Google 联系人分组",
"type": "n8n-nodes-base.httpRequest",
"position": [
1180,
240
],
"parameters": {
"url": "https://people.googleapis.com/v1/contactGroups",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "pageSize",
"value": "1000"
}
]
},
"nodeCredentialType": "googleContactsOAuth2Api"
},
"credentials": {},
"typeVersion": 4.2
},
{
"id": "d9660c1f-9672-4cf0-8196-fee0b0acb8d3",
"name": "检查 Google 联系人分组是否存在",
"type": "n8n-nodes-base.if",
"position": [
1640,
240
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f8e38a64-ace8-49e8-b400-c6609db670e9",
"operator": {
"type": "array",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json.resourceName }}",
"rightValue": "null"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "c913cf75-f9eb-4b27-b5f3-5bae32ee0d86",
"name": "在 Notion 中标记联系人为已同步",
"type": "n8n-nodes-base.notion",
"position": [
2080,
240
],
"parameters": {
"pageId": {
"__rl": true,
"mode": "url",
"value": "={{ $('Get All Contacts from Notion').item.json.url }}"
},
"options": {},
"resource": "databasePage",
"operation": "update",
"propertiesUi": {
"propertyValues": [
{
"key": "Added to Contacts|checkbox",
"checkboxValue": true
}
]
}
},
"credentials": {},
"typeVersion": 2.2
},
{
"id": "d8f8f322-26c2-4c22-bc74-22db9c67cfd3",
"name": "创建新的 Google 联系人分组",
"type": "n8n-nodes-base.httpRequest",
"position": [
1640,
40
],
"parameters": {
"url": "https://people.googleapis.com/v1/contactGroups",
"method": "POST",
"options": {},
"jsonBody": "={\n \"contactGroup\": {\n \"name\": \"{{ $json.name }}\"\n }\n} ",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleContactsOAuth2Api"
},
"credentials": {},
"typeVersion": 4.2
},
{
"id": "8e01eb00-ba8b-495b-bcec-38c50d631357",
"name": "检查联系人是否已同步",
"type": "n8n-nodes-base.if",
"position": [
980,
240
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a707ab4a-4300-4626-bc72-d0bd6126f733",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $('Map Notion Contact Fields').item.json['Already Added'].toBoolean() }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "7a218d3f-9a76-4f21-a599-f550f3642159",
"name": "新 Notion 联系人触发",
"type": "n8n-nodes-base.notionTrigger",
"position": [
40,
160
],
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyWeek"
}
]
},
"databaseId": {
"__rl": true,
"mode": "id",
"value": "Enter your Notion database ID here."
}
},
"credentials": {},
"typeVersion": 1
},
{
"id": "871cfdb2-8353-4347-8b96-23d0deacb3cd",
"name": "更新的 Notion 联系人触发",
"type": "n8n-nodes-base.notionTrigger",
"position": [
40,
360
],
"parameters": {
"event": "pagedUpdatedInDatabase",
"pollTimes": {
"item": [
{
"mode": "everyWeek"
}
]
},
"databaseId": {
"__rl": true,
"mode": "id",
"value": "Enter your Notion database ID here."
}
},
"credentials": {},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "c0a0f606-780f-4f03-95d9-6d7ad6c12790",
"connections": {
"Find Match Labels": {
"main": [
[
{
"node": "Check Google Contact Group Exists",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Contacts": {
"main": [
[],
[
{
"node": "Check if Contact Already Synced",
"type": "main",
"index": 0
}
]
]
},
"Map Notion Contact Fields": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
]
]
},
"Fetch Google Contact Groups": {
"main": [
[
{
"node": "Find Match Labels",
"type": "main",
"index": 0
}
]
]
},
"Get All Contacts from Notion": {
"main": [
[
{
"node": "Map Notion Contact Fields",
"type": "main",
"index": 0
}
]
]
},
"Trigger on New Notion Contact": {
"main": [
[
{
"node": "Get All Contacts from Notion",
"type": "main",
"index": 0
}
]
]
},
"Add Contact to Google Contacts": {
"main": [
[
{
"node": "Mark Contact as Synced in Notion",
"type": "main",
"index": 0
}
]
]
},
"Check if Contact Already Synced": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
],
[
{
"node": "Fetch Google Contact Groups",
"type": "main",
"index": 0
}
]
]
},
"Create New Google Contact Group": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
]
]
},
"Mark Contact as Synced in Notion": {
"main": [
[
{
"node": "Loop Over Contacts",
"type": "main",
"index": 0
}
]
]
},
"Check Google Contact Group Exists": {
"main": [
[
{
"node": "Create New Google Contact Group",
"type": "main",
"index": 0
}
],
[
{
"node": "Add Contact to Google Contacts",
"type": "main",
"index": 0
}
]
]
},
"Trigger on Updated Notion Contact": {
"main": [
[
{
"node": "Get All Contacts from Notion",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客户关系管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
我的工作流12
通过网络爬取、LinkedIn数据和GPT-4o自动丰富Salesforce账户信息
If
Set
Code
+8
30 节点Le Nguyen
客户关系管理
双向同步 Google 通讯录与 Notion
双向同步 Google 通讯录与 Notion
If
Set
Merge
+9
82 节点Solomon
其他
博客与LinkedIn内容创作自动化
使用OpenAI和Replicate AI图像自动化博客与LinkedIn内容创作
If
Set
Code
+9
28 节点Sagar Budhathoki
内容创作
从 Notion 内容创建 Linear 工单
从 Notion 内容创建 Linear 工单
If
Set
Code
+11
24 节点David Roberts
工程
使用Gemini和GPT从笔记和语音创建结构化Notion工作区
使用Gemini和GPT从笔记和语音创建结构化Notion工作区
If
Set
Code
+14
36 节点Alex Huy
多模态 AI
Reels趋势观察器
使用Gemini和Apify查找高表现Instagram Reels并将洞察保存至Notion
If
Set
Code
+9
36 节点Eugene Green
市场调研