Gmail元数据提取到Google Sheet
中级
这是一个Ticket Management领域的自动化工作流,包含 7 个节点。主要使用 Set、Code、GmailTrigger、GoogleSheets 等节点。 将Gmail元数据提取到Google Sheets
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
使用的节点 (7 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Mw3kkNKzGTQ5hB2t",
"meta": {
"instanceId": "ac3395400729d0f53e6b8e43c425ec1af04a99e154bcd808417b3b72fa9dec1f",
"templateCredsSetupCompleted": true
},
"name": "将 Gmail 元数据提取到 Google Sheet",
"tags": [],
"nodes": [
{
"id": "ab804462-804b-4c33-8d17-b9b950ec41b9",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-640,
0
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "F9eGgjqXjaly1d2v",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "30dabca0-384f-4df5-b4bb-87a029584a92",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
-20,
0
],
"parameters": {
"jsCode": "// Try to pull subject from different common locations\nconst subject =\n $json.subject ||\n $json.Subject ||\n $json.headers?.subject ||\n \"No Subject\";\n\n// Try to pull body text from common fields\nconst body =\n $json.body ||\n $json.text ||\n $json.snippet ||\n \"No message found.\";\n\n// Try to pull \"from\" field from common sources\nconst fromHeader =\n $json.from ||\n $json.From ||\n $json.headers?.from ||\n \"\";\n\n// Initialize name and email placeholders\nlet senderName = \"\";\nlet email = \"\";\n\n// Extract \"Name <email@example.com>\" if present\nconst match = fromHeader.match(/(.*?)<(.+?)>/);\nif (match) {\n senderName = match[1].trim();\n email = match[2].trim();\n} else {\n // If only email address is provided\n email = fromHeader.trim();\n}\n\n// Attempt to extract name from message body like: \"I am John Doe from ...\"\nlet extractedName = \"\";\nconst nameMatch = body.match(/I am (.*?) from/i);\nif (nameMatch) {\n extractedName = nameMatch[1].trim();\n}\n\n// Choose final name: prefer extracted from body, else senderName, else fallback\nconst finalName = extractedName || senderName || \"Unknown\";\n\nreturn [{\n json: {\n name: finalName,\n email,\n subject,\n message: body,\n timestamp: new Date().toISOString()\n }\n}];\n"
},
"typeVersion": 2
},
{
"id": "99aadc61-1a46-45ee-8f92-4159ffd3d8f7",
"name": "获取简报",
"type": "n8n-nodes-base.set",
"position": [
540,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "9ad38b82-4d5e-4ec5-9f7e-69142b7576a8",
"name": "Full Name",
"type": "string",
"value": "={{ $json.name }}"
},
{
"id": "fae560c7-88e1-40d8-9721-fc8136646c26",
"name": "Email Address",
"type": "string",
"value": "={{ $json.email }}"
},
{
"id": "6764dbcd-beb0-44c1-a235-bf1c5da47b3d",
"name": "Subject",
"type": "string",
"value": "={{ $json.subject }}"
},
{
"id": "47bfeda7-805c-43ea-afd6-50b1a6851619",
"name": "Body of the email",
"type": "string",
"value": "={{ $json.message }}"
},
{
"id": "fee870b7-0d55-4a66-b9d8-7ad6e6b35107",
"name": "Time",
"type": "string",
"value": "={{ $json.timestamp }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f81a918b-3f2b-4f07-b9c2-89aa98b1ce36",
"name": "在表格中添加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
940,
0
],
"parameters": {
"columns": {
"value": {
"Tme": "={{ $json.Time }}",
"Name": "={{ $json['Full Name'] }}",
"Subject": "={{ $json.Subject }}",
"Email Address": "={{ $json['Email Address'] }}",
"Body of the email": "={{ $json['Body of the email'] }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Email Address",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Email Address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Subject",
"type": "string",
"display": true,
"required": false,
"displayName": "Subject",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Body of the email",
"type": "string",
"display": true,
"required": false,
"displayName": "Body of the email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Tme",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Tme",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Email Address"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/11nRQWiVvGWIbeUhEJIi0EL5dh3KuoSqZCuXv3ktBjxI/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "11nRQWiVvGWIbeUhEJIi0EL5dh3KuoSqZCuXv3ktBjxI",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/11nRQWiVvGWIbeUhEJIi0EL5dh3KuoSqZCuXv3ktBjxI/edit?usp=drivesdk",
"cachedResultName": "Email Data"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "kGYmhjcnx8Fu3k1c",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "03af6ae2-7b35-4b26-ac11-04289a7376a9",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
-1320
],
"parameters": {
"color": 4,
"width": 460,
"height": 1480,
"content": "## 它从传入的电子邮件或表单提交中提取有用的详细信息(如姓名、电子邮件、主题和消息)——即使数据格式各不相同。"
},
"typeVersion": 1
},
{
"id": "c6f941e6-8392-4055-9c75-e8e0b940c73b",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-780,
-160
],
"parameters": {
"width": 340,
"height": 320,
"content": "## Gmail 在新邮件到达时触发"
},
"typeVersion": 1
},
{
"id": "0a6106ac-648e-4f57-baf9-829746f6fecc",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1800,
-720
],
"parameters": {
"color": 3,
"width": 900,
"height": 1920,
"content": "## 此自动化流程的作用(简单来说)"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "7facb1ff-d4dc-4141-b177-ca28725fcfb8",
"connections": {
"Code": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于Ticket Management等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
AI驱动的客户支持:邮件、知识库与人工升级自动化
AI邮件支持系统:集成Gmail、Gemini、GPT-4、Slack和Google Sheets的工作流程
Set
Gmail
Slack
+13
26 节点David Olusola
Ticket Management
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
Set
Code
Gmail
+13
37 节点gotoHuman
Ticket Management
使用GPT、Gmail、Slack和分析仪表板自动分诊客户支持
使用GPT、Gmail、Slack和分析仪表板自动分诊客户支持
Code
Slack
Open Ai
+5
21 节点Daniel Shashko
Ticket Management
AI 客户支持分流与摘要系统
使用GPT-4o、Slack和CRM集成自动处理客户支持
If
Set
Code
+10
32 节点NodeAlchemy
Ticket Management
使用 Gmail、Groq AI 和 Google Sheets 自动化邮件过滤与 AI 摘要
使用 Gmail、Groq AI 和 Google Sheets 自动化邮件过滤与 AI 摘要
If
Code
Gmail Trigger
+4
14 节点ARRE
Ticket Management
具有 AI 分类、Gmail 草稿和 Slack 通知的智能电子邮件助手
使用 OpenAI 分类、Gmail 草稿和 Slack 提醒实现邮件管理自动化
Set
Code
Gmail
+6
16 节点Fabian ZNTL
Ticket Management