使用Gmail API自动每月清理Gmail垃圾邮件文件夹
这是一个Personal Productivity领域的自动化工作流,包含 8 个节点。主要使用 Wait, Gmail, ScheduleTrigger 等节点。 使用Gmail API每月自动清理Gmail垃圾邮件文件夹
- •Google 账号和 Gmail API 凭证
使用的节点 (8)
分类
{
"id": "hdBpjh9528K5FyWV",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "使用Gmail API自动每月清理Gmail垃圾邮件文件夹",
"tags": [],
"nodes": [
{
"id": "e214c477-6d39-426f-8a34-cd38bb6f5ae2",
"name": "每月触发器(第1天)",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-380,
120
],
"parameters": {
"rule": {
"interval": [
{
"field": "months",
"triggerAtHour": 6
}
]
}
},
"typeVersion": 1.2
},
{
"id": "e8eb600c-9b45-44e2-8ee6-409c9b61b171",
"name": "获取垃圾邮件(Gmail)",
"type": "n8n-nodes-base.gmail",
"position": [
-160,
120
],
"webhookId": "c47419de-278c-40d1-a5da-c9414d3f89c6",
"parameters": {
"filters": {
"labelIds": [
"SPAM"
]
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "PcTqvGU9uCunfltE",
"name": "Gmail account - test"
}
},
"typeVersion": 2.1
},
{
"id": "96a0fd3c-63bd-48f4-87d7-7eda528b50a3",
"name": "删除前暂停(5秒)",
"type": "n8n-nodes-base.wait",
"position": [
60,
120
],
"webhookId": "0b2f9902-fd7b-4a98-87a3-f36c74b0af32",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "e172bbb8-069c-4c68-b72f-cf2a7f304f0b",
"name": "删除获取的垃圾邮件",
"type": "n8n-nodes-base.gmail",
"position": [
280,
120
],
"webhookId": "46b0fe0f-cc00-4994-8364-9048c888e9ef",
"parameters": {
"messageId": "={{ $json.id }}",
"operation": "delete"
},
"credentials": {
"gmailOAuth2": {
"id": "PcTqvGU9uCunfltE",
"name": "Gmail account - test"
}
},
"typeVersion": 2.1
},
{
"id": "a07dd87f-1216-44de-91b8-a6d7d36877e8",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-415,
-80
],
"parameters": {
"color": 3,
"width": 170,
"height": 360,
"content": "每月第1天自动启动工作流执行邮件清理。"
},
"typeVersion": 1
},
{
"id": "0de7be15-2ebe-4c28-ab52-59f35f6a3135",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
-80
],
"parameters": {
"color": 5,
"width": 170,
"height": 360,
"content": "使用Gmail API检索经过身份验证的Gmail账户垃圾邮件文件夹中的所有邮件。"
},
"typeVersion": 1
},
{
"id": "11c0f2f1-1480-4512-ad4d-1d9544838e2c",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
20,
-80
],
"parameters": {
"width": 170,
"height": 360,
"content": "引入短暂延迟以避免触及Gmail的API速率限制或确保所有邮件正确获取。"
},
"typeVersion": 1
},
{
"id": "0600f919-8315-431a-8420-9c0931b9c097",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
-80
],
"parameters": {
"color": 4,
"width": 170,
"height": 360,
"content": "永久删除从垃圾邮件文件夹检索的所有邮件以释放Gmail空间并改善邮件卫生。"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "ad4a18bb-1aff-4520-9e68-4844bf365d8f",
"connections": {
"Fetch SPAM Emails (Gmail)": {
"main": [
[
{
"node": "Pause Before Deletion (5s)",
"type": "main",
"index": 0
}
]
]
},
"Monthly Trigger (1st Day)": {
"main": [
[
{
"node": "Fetch SPAM Emails (Gmail)",
"type": "main",
"index": 0
}
]
]
},
"Pause Before Deletion (5s)": {
"main": [
[
{
"node": "Delete Fetched SPAM Emails",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 个人效率
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
分享此工作流