模板:处理Gmail中的附件文件
高级
这是一个File Management领域的自动化工作流,包含 22 个节点。主要使用 Gmail, Slack, Filter, Switch, SplitOut 等节点。 Gmail附件管理器,含Google Drive上传和智能筛选
前置要求
- •Google 账号和 Gmail API 凭证
- •Slack Bot Token 或 Webhook URL
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
使用的节点 (22)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Z3wOGZdXKSlSWzgO",
"meta": {
"instanceId": "5b61629a145a38a93588ff78addb36f97647fd75c5392fcb856e858941f87d19",
"templateCredsSetupCompleted": true
},
"name": "TEMPLATE Process attached files in Gmail",
"tags": [],
"nodes": [
{
"id": "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364",
"name": "Mark read and archive email",
"type": "n8n-nodes-base.gmail",
"position": [
-80,
-80
],
"webhookId": "0dd820ff-1f3e-4e9e-9fb8-922f59eabf8c",
"parameters": {
"labelIds": [
"UNREAD",
"INBOX"
],
"messageId": "={{ $('Filter based on sender or receiver').item.json.id }}",
"operation": "removeLabels"
},
"credentials": {},
"typeVersion": 2.1
},
{
"id": "1327a765-2c40-40ef-929f-dfb0790cf048",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
-560
],
"parameters": {
"color": 5,
"width": 1344,
"height": 432,
"content": "## Information\nTemplate created by Smultron Studio (https://smultronstudio.com/en) - feel free to reach out at hello@smultronstudio.com\n\n### Instructions (numbers refer to red cards):\n1. Configure credentials\n2. Configure credentials\n3. If you have one or many specific senders for the emails to be processed in this workflow, specify here\n4. If you want a filter on which file types to process, specify here\n5. If you want to process multiple file types and need separate paths, build that here\n6. Configure where to post or upload the files\n7. Configure credentials and customize Slack message\n\n#### Modifications:\nThis template is a skeleton to customize for your use case. It sorts out the n8n specific references and logic to process the files fetched from an email in Gmail.\n\n#### List of mimeTypes for filtering:\nhttps://docs.cloud.google.com/appengine/docs/legacy/standard/php/mail/mail-with-headers-attachments"
},
"typeVersion": 1
},
{
"id": "f50f6e40-1b10-48da-9440-1cffe6f6d323",
"name": "Send a message",
"type": "n8n-nodes-base.slack",
"position": [
592,
-336
],
"webhookId": "92ba6b9b-92d1-47a8-bf51-103a5598212d",
"parameters": {
"text": "=Did something with {{$('Loop attachments').all().length}} files received from {{ $('Trigger on incoming email with attachment').item.json.from.value[0].address }}",
"otherOptions": {}
},
"typeVersion": 2.3
},
{
"id": "5c972c0f-dc9f-4056-a4b5-99bd62ea1a83",
"name": "Trigger on incoming email with attachment",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-864,
80
],
"parameters": {
"simple": false,
"filters": {
"q": "has:attachment -label:DRAFT"
},
"options": {
"downloadAttachments": true
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {},
"typeVersion": 1.3
},
{
"id": "d4504562-3549-4d70-8b60-37e8c027adc7",
"name": "Filter based on file type",
"type": "n8n-nodes-base.filter",
"position": [
144,
144
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "5b96c7b7-5896-4e65-89e2-69e679346f42",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $binary.values()[0].mimeType }}",
"rightValue": "application/zip"
},
{
"id": "ac183995-c533-4698-a2e7-8601f7420c79",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $binary.values()[0].mimeType }}",
"rightValue": "text/plain"
},
{
"id": "0a949152-7478-4b66-a2c2-e52798627eba",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $binary.values()[0].mimeType }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2,
"alwaysOutputData": true
},
{
"id": "75ebfebd-0d76-45e1-b722-6ebcc159460d",
"name": "Treat different file types different",
"type": "n8n-nodes-base.switch",
"position": [
368,
128
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "zip",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "48e9243a-8e5b-4f5d-90e7-4c78b0580a76",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $binary.values()[0].mimeType }}",
"rightValue": "application/zip"
}
]
},
"renameOutput": true
},
{
"outputKey": "no file",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c9b50caa-7335-469f-a863-e24836c1ca79",
"operator": {
"type": "object",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $input.first().json }}",
"rightValue": "0"
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.3
},
{
"id": "e653ee4e-cf13-4d51-b43b-79920f5add10",
"name": "Decompress zip",
"type": "n8n-nodes-base.compression",
"position": [
528,
48
],
"parameters": {
"outputPrefix": "=file_",
"binaryPropertyName": "={{ Object.keys($binary)[0] }}"
},
"typeVersion": 1.1
},
{
"id": "faf61d9d-2e43-4c6c-b23c-08c85042e1fe",
"name": "Post file to webhook",
"type": "n8n-nodes-base.httpRequest",
"position": [
1056,
272
],
"parameters": {
"url": "https://n8n.com:8443/webhook/[unique-id]",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "binaryData",
"inputDataFieldName": "={{ Object.keys($binary)[0] }}"
},
"typeVersion": 4.2
},
{
"id": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
"name": "Loop attachments",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-272,
80
],
"parameters": {
"options": {
"reset": false
}
},
"typeVersion": 3
},
{
"id": "febc18da-137c-4759-b21d-ec1910778a98",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
-112
],
"parameters": {
"color": 6,
"width": 1904,
"height": 560,
"content": ""
},
"typeVersion": 1
},
{
"id": "9ebd9a7e-bc46-4d8c-81b9-c621394683a0",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
432,
-560
],
"parameters": {
"width": 544,
"height": 432,
"content": "## Notification out\nNotify in Slack that files has been processed"
},
"typeVersion": 1
},
{
"id": "512d195b-ffab-42db-9c60-dd9f60cde8fe",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
64
],
"parameters": {
"color": 3,
"width": 192,
"height": 448,
"content": "## 6. Upload file somewhere\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nConfigure or replace this node with some other destination for your files."
},
"typeVersion": 1
},
{
"id": "44de5019-f2fd-4c87-bc91-a3c789b18ae5",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
16
],
"parameters": {
"color": 3,
"width": 192,
"height": 496,
"content": "## 4. Filter based on file type\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect one or more file types, you can specify that here. \n\nOr if you only want to process a specific file type in emails with multiple attachments."
},
"typeVersion": 1
},
{
"id": "3260063c-d547-418e-af65-2de4f80eaf35",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
0
],
"parameters": {
"color": 3,
"width": 368,
"height": 512,
"content": "## 5. Treat different file types separate\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect multiple file types that requires different processing, build those paths here (like decompressing zip files). \n\nIf you filter to only process one specific file type or will process all files the same then you can remove this part. "
},
"typeVersion": 1
},
{
"id": "79a0bfcf-c12a-4c78-af7a-7174a9f6c8e0",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-912,
-16
],
"parameters": {
"color": 3,
"width": 192,
"height": 272,
"content": "## 1. Trigger\nConfigure your credentials here"
},
"typeVersion": 1
},
{
"id": "f25b842d-2324-42f2-9f4a-847098d2669f",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-128,
-176
],
"parameters": {
"color": 3,
"width": 192,
"height": 288,
"content": "## 2. Archive\nConfigure your credentials here"
},
"typeVersion": 1
},
{
"id": "367f6c68-5b16-4062-8be8-8a5094b24c0a",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-704,
-16
],
"parameters": {
"color": 3,
"width": 208,
"height": 272,
"content": "## 3. Filter sender/receiver\n"
},
"typeVersion": 1
},
{
"id": "16094578-c919-4cd3-8a6b-4bf730426f11",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
544,
-448
],
"parameters": {
"color": 3,
"height": 288,
"content": "## 7. Slack notification\nConfigure your credentials here"
},
"typeVersion": 1
},
{
"id": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
"name": "Upload file to Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
768,
160
],
"parameters": {
"name": "={{ $binary.values()[0].fileName }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root",
"cachedResultName": "/ (Root folder)"
},
"inputDataFieldName": "={{ Object.keys($binary)[0] }}"
},
"credentials": {},
"typeVersion": 3
},
{
"id": "44a5eaa9-181c-4871-9a66-00927e293dd0",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
992,
176
],
"parameters": {
"color": 3,
"width": 256,
"height": 272,
"content": "## 8. Example\nThis is a webhook example to replace the Google Drive node (6)"
},
"typeVersion": 1
},
{
"id": "95604855-1bf5-485c-bd31-65b4352b6cec",
"name": "Filter based on sender or receiver",
"type": "n8n-nodes-base.filter",
"position": [
-656,
80
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "dab0779d-b14a-481c-80d6-33c356009ef5",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.from.value[0].address }}",
"rightValue": "sender@domain.tld"
},
{
"id": "09479cf5-3c9a-4dab-a987-016462db5470",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.to.value[0].address }}",
"rightValue": "recipient@domain.tld"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"position": [
-448,
80
],
"parameters": {
"options": {},
"fieldToSplitOut": "$binary"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "8fd24c8f-f0fe-48e5-bf27-da6a79d17f5e",
"connections": {
"Split Out": {
"main": [
[
{
"node": "Loop attachments",
"type": "main",
"index": 0
}
]
]
},
"Decompress zip": {
"main": [
[
{
"node": "Upload file to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Send a message": {
"main": [
[]
]
},
"Loop attachments": {
"main": [
[
{
"node": "Mark read and archive email",
"type": "main",
"index": 0
}
],
[
{
"node": "Filter based on file type",
"type": "main",
"index": 0
}
]
]
},
"Post file to webhook": {
"main": [
[]
]
},
"Filter based on file type": {
"main": [
[
{
"node": "Treat different file types different",
"type": "main",
"index": 0
}
]
]
},
"Mark read and archive email": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
]
]
},
"Upload file to Google Drive": {
"main": [
[
{
"node": "Loop attachments",
"type": "main",
"index": 0
}
]
]
},
"Filter based on sender or receiver": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Treat different file types different": {
"main": [
[
{
"node": "Decompress zip",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop attachments",
"type": "main",
"index": 0
}
],
[
{
"node": "Upload file to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Trigger on incoming email with attachment": {
"main": [
[
{
"node": "Filter based on sender or receiver",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 文件管理
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在Google Drive文件夹中整理邮件附件
根据发件人邮箱在Google Drive文件夹中整理Gmail附件
If
Set
Code
+10
17 节点Davide
文件管理
AI个性化多产品邮件营销
基于SMTP轮换的AI个性化多产品邮件营销(GPT-4o/o3-mini)
If
Code
Wait
+16
41 节点Badr
销售
API架构提取器
API架构提取器
If
Set
Code
+22
88 节点Polina Medvedieva
工程
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
Set
Code
Gmail
+13
37 节点gotoHuman
工单管理
潜在客户开发与邮件工作流
使用Google Maps、SendGrid和AI自动化B2B潜在客户开发与邮件营销
If
Set
Code
+21
141 节点Ezema Kingsley Chibuzo
潜在客户开发
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
工作流信息
难度等级
高级
节点数量22
分类1
节点类型11
作者
Ossian Madisson
@ossianAI & Automation consultant with many years of experience from both devops and business management. A solid combination to really understand where technology can create real business value. My focus is to help businesses in Sweden work smarter and achieve more by applying technology in a useful and responsible way. Feel free to contact me at ossian@smultronstudio.com or schedule a short call at https://smultronstudio.com
外部链接
在 n8n.io 查看 →
分享此工作流