邮件摘要
中级
这是一个Personal Productivity, AI Summarization领域的自动化工作流,包含 11 个节点。主要使用 If, Code, Gmail, Limit, GoogleDocs 等节点。 使用GPT-4摘要到Google文档的每日邮件摘要
前置要求
- •Google 账号和 Gmail API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "p5e76vbOIDIaf29H",
"meta": {
"instanceId": "6304e8877aa0fde3913b14034debe07006963fb497d63f280a91bbd75c6c24e1",
"templateCredsSetupCompleted": true
},
"name": "邮件摘要",
"tags": [
{
"id": "TNPHEZ52JXA88tV0",
"name": "AI",
"createdAt": "2025-06-28T18:46:13.842Z",
"updatedAt": "2025-06-28T18:46:13.842Z"
},
{
"id": "pD2RVg49fBlIR8pA",
"name": "Gmail",
"createdAt": "2025-06-28T19:24:47.979Z",
"updatedAt": "2025-06-28T19:24:47.979Z"
},
{
"id": "wZ14hcyo2pYAOVlF",
"name": "OpenAI",
"createdAt": "2025-06-28T18:46:13.462Z",
"updatedAt": "2025-06-28T18:46:13.462Z"
},
{
"id": "M3TlU8Xdj7ZlK0PE",
"name": "Project Management",
"createdAt": "2025-06-28T18:46:13.681Z",
"updatedAt": "2025-06-28T18:46:13.681Z"
},
{
"id": "bpJw62xLnDDElGob",
"name": "Building blocks",
"createdAt": "2025-06-28T18:46:13.530Z",
"updatedAt": "2025-06-28T18:46:13.530Z"
},
{
"id": "3nY5Wk7HNEt9e9gW",
"name": "DevOps",
"createdAt": "2025-06-28T18:46:13.916Z",
"updatedAt": "2025-06-28T18:46:13.916Z"
},
{
"id": "1Z9wnauckk6RWoYl",
"name": "Email",
"createdAt": "2025-07-19T17:42:50.746Z",
"updatedAt": "2025-07-19T17:42:50.746Z"
}
],
"nodes": [
{
"id": "10e1dc39-0561-4bfd-b80f-e60a91af3cb5",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-60
],
"parameters": {
"width": 1880,
"height": 460,
"content": "Telegram 邮件摘要工作流"
},
"typeVersion": 1
},
{
"id": "ef07131c-2d2c-42ed-a1de-7e5625c8057c",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-720
],
"parameters": {
"color": 3,
"width": 580,
"height": 640,
"content": "邮件摘要工作流:"
},
"typeVersion": 1
},
{
"id": "28c3ca0d-9397-41e3-b8b9-13a577e0ca98",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-40,
100
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 8
}
]
}
},
"typeVersion": 1.2
},
{
"id": "da1aaa80-87a6-4d98-b14f-e08e327553bc",
"name": "限制",
"type": "n8n-nodes-base.limit",
"position": [
340,
100
],
"parameters": {},
"typeVersion": 1
},
{
"id": "54653ec9-413f-4656-955c-3dcaacdee6cf",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"position": [
540,
100
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "621c437c-e857-4e21-9aa6-ed75ae360775",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $('Get Gmail').item.json.headers.from }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f6b7ea0d-b521-459d-856c-f39a26962356",
"name": "邮件",
"type": "n8n-nodes-base.code",
"position": [
800,
0
],
"parameters": {
"jsCode": "// This function will strip out HTML tags to leave only the plain text.\nfunction extractCleanText(html) {\n if (!html) {\n return '';\n }\n // A regular expression to remove HTML tags and extra whitespace.\n return html.replace(/<[^>]*>/g, \"\").replace(/\\s+/g, ' ').trim();\n}\n\n// Process each email item passed to the node.\nreturn $input.all().map(item => {\n const payload = item.json.payload || {};\n const headers = payload.headers || [];\n \n // A helper function to find a specific header's value.\n const getHeader = (name) => headers.find(h => h.name.toLowerCase() === name.toLowerCase())?.value || 'N/A';\n\n const from = getHeader('From');\n const subject = getHeader('Subject');\n const date = getHeader('Date');\n\n let bodyData = '';\n // Check for multipart emails first.\n if (payload.parts) {\n // Prefer plain text over HTML for simplicity.\n const plainPart = payload.parts.find(p => p.mimeType === 'text/plain');\n const htmlPart = payload.parts.find(p => p.mimeType === 'text/html');\n \n // Use the data from the preferred part.\n if (plainPart && plainPart.body && plainPart.body.data) {\n bodyData = plainPart.body.data;\n } else if (htmlPart && htmlPart.body && htmlPart.body.data) {\n bodyData = htmlPart.body.data;\n }\n } else if (payload.body && payload.body.data) {\n // Fallback for single-part emails.\n bodyData = payload.body.data;\n }\n\n // The body content is Base64 encoded, so it needs to be decoded.\n const decodedBody = Buffer.from(bodyData, 'base64').toString('utf-8');\n \n // Clean the decoded body to remove any lingering HTML.\n const cleanBody = extractCleanText(decodedBody);\n\n return {\n json: {\n from,\n subject,\n date,\n body: cleanBody\n }\n };\n});"
},
"typeVersion": 2
},
{
"id": "6967e64d-32ac-4981-969b-76719d0b0377",
"name": "无邮件",
"type": "n8n-nodes-base.code",
"position": [
800,
240
],
"parameters": {
"jsCode": "return [\n {\n json: {\n from: \"N/A\",\n subject: \"No Email Found\",\n date: new Date().toISOString(),\n body: \"No new emails were found during this summary check. There is nothing to summarize at this time.\"\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "a0e30b66-7329-4731-9401-5896855a7a22",
"name": "获取 Gmail",
"type": "n8n-nodes-base.gmail",
"position": [
160,
100
],
"webhookId": "efcd3ee6-26a7-4c3d-84c2-c1cdef8a8d7c",
"parameters": {
"limit": 1,
"simple": false,
"filters": {},
"options": {},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "B0oVer8pX52LHrvw",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "a931d85d-40ea-4bde-a0aa-8f9a7ef14c04",
"name": "邮件摘要 OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1060,
120
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1",
"cachedResultName": "GPT-4.1"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are a professional AI assistant tasked with summarizing the most recent email received.\n\nYour goal is to deliver a clear, concise, and accurate summary that saves the user time by eliminating the need to read the full email. The summary should convey all essential details and maintain a professional tone.\n\nPlease include the following in your response:\n\nSender's name and email address: {{ $('Get Gmail').item.json.headers.from }}\n\nDate and time received: {{ $('Get Gmail').item.json.headers.date }}\n\nSubject line (if available): {{ $('Get Gmail').item.json.headers.subject }}\n\nMain purpose or topic of the email\n\nKey points, requests, or required actions\n\nAny additional relevant context that helps the user understand the email at a glance\n\nAvoid unnecessary repetition or filler. The summary should be easy to scan, but detailed enough that the user can fully understand the message without opening the original email.\n\nSummarize the following content:\n\n{{ $('Get Gmail').item.json.text }}"
}
]
},
"simplify": false
},
"credentials": {
"openAiApi": {
"id": "Yks1Eic3YR07Cpm6",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "537c41f8-5cea-46d6-92a9-a2cffdd65bb2",
"name": "创建 Google Docs",
"type": "n8n-nodes-base.googleDocs",
"position": [
1420,
120
],
"parameters": {
"title": "Email Summary",
"folderId": "1ihoRENubwDmcwMqhFzbdnfuYQdU2YXVR"
},
"credentials": {
"googleDocsOAuth2Api": {
"id": "dSGiWWxQdhY5ywpg",
"name": "Google Docs account"
}
},
"typeVersion": 2
},
{
"id": "96ca547a-cb62-4eef-a9dc-765654c13e1d",
"name": "更新 Google 文档",
"type": "n8n-nodes-base.googleDocs",
"position": [
1620,
120
],
"parameters": {
"simple": false,
"actionsUi": {
"actionFields": [
{
"text": "={{ $('Summary Email OpenAI').item.json.choices[0].message.content }}",
"action": "insert"
}
]
},
"operation": "update",
"documentURL": "={{ $json.id }}"
},
"credentials": {
"googleDocsOAuth2Api": {
"id": "dSGiWWxQdhY5ywpg",
"name": "Google Docs account"
}
},
"typeVersion": 2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "bf63aae4-7580-4cb7-93ab-9631974dc104",
"connections": {
"If": {
"main": [
[
{
"node": "Email",
"type": "main",
"index": 0
}
],
[
{
"node": "No Email",
"type": "main",
"index": 0
}
]
]
},
"Email": {
"main": [
[
{
"node": "Summary Email OpenAI",
"type": "main",
"index": 0
}
]
]
},
"Limit": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"No Email": {
"main": [
[
{
"node": "Summary Email OpenAI",
"type": "main",
"index": 0
}
]
]
},
"Get Gmail": {
"main": [
[
{
"node": "Limit",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Gmail",
"type": "main",
"index": 0
}
]
]
},
"Create Google Docs": {
"main": [
[
{
"node": "Update Google Docs",
"type": "main",
"index": 0
}
]
]
},
"Summary Email OpenAI": {
"main": [
[
{
"node": "Create Google Docs",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 个人效率, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Gmail→GPT→Supabase任务提取器
使用Gmail、ChatGPT-4o和Supabase提取邮件任务
If
Code
Gmail
+6
9 节点Paul Taylor
个人效率
从PDF起草摘要工作流
使用Google Drive、GPT-4和邮件通知从PDF生成专业文档草稿
Set
Code
Gmail
+8
14 节点Michael Gullo
文档提取
每日商业新闻
使用OpenAI和Gmail从多个RSS源生成每日商业新闻摘要
If
Code
Gmail
+7
15 节点Calistus Christian
市场调研
每日安全新闻
每日技术与网络安全简报:RSS、OpenAI GPT-4o 和 Gmail
If
Code
Gmail
+7
19 节点Calistus Christian
个人效率
工作日日志记录
AI工时表生成器 - 集成Gmail、日历和GitHub到Google表格
If
Set
Code
+11
31 节点Luka Zivkovic
个人效率
使用 Mistral AI、LinkedIn 和 Google Sheets 自动化职位搜索与简历定制
使用 Mistral AI、LinkedIn 和 Google Sheets 自动化职位搜索与简历定制
Set
Code
Html
+18
46 节点Jordan Hoyle
个人效率
工作流信息
难度等级
中级
节点数量11
分类2
节点类型8
作者
Michael Gullo
@drdoomI’m passionate about using n8n to create realistic workflows that help working class people simplify their daily tasks. My workflows aim to make life easier by eliminating mundane, repetitive responsibilities that take up valuable time. I love turning automation into a tool that lets people focus on what matters most to them.
外部链接
在 n8n.io 查看 →
分享此工作流