8
n8n 中文网amn8n.com

自动分类个人收件箱

高级

这是一个Personal Productivity, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 Set, Code, Gmail, Notion, Aggregate 等节点。 使用 Gmail、GPT-4o-mini 和 Notion 自动化邮件分类与摘要

前置要求
  • Google 账号和 Gmail API 凭证
  • Notion API Key
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "RGhw0UmEtucowCuk",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
    "templateCredsSetupCompleted": true
  },
  "name": "自动分类个人收件箱",
  "tags": [],
  "nodes": [
    {
      "id": "cba3ea9b-89d2-4ef4-a5fd-6cd4c06fd71c",
      "name": "获取未读邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        48,
        -32
      ],
      "parameters": {
        "resource": "message",
        "operation": "getAll",
        "additionalFields": {
          "labelIds": [
            "UNREAD",
            "INBOX"
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "RchiXdmY8WaQhOSJ",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cb5df628-43a2-4946-8227-3597ce9a85a3",
      "name": "拆分邮件",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        272,
        -32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "abc26329-6683-4e9a-a1f7-c95e104d051d",
      "name": "格式化摘要",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        -32
      ],
      "parameters": {
        "jsCode": "// Get the AI classification output (e.g., \"Important\")\nconst classification = $input.first().json.text.trim();\n\n// Get original email data from the \"Split Emails\" node\nconst email = $('Split Emails').first().json;\n\n// Fallbacks in case fields are missing\nconst subject = email.headers?.subject || email.subject || \"No Subject\";\nconst from = email.headers?.from || email.from || \"Unknown Sender\";\n\n// Build the summary line\nconst summary = `**${classification}**: ${subject} (from: ${from})`;\n\n// Return the structured result\nreturn [{\n  json: {\n    classification,\n    subject,\n    from,\n    summary\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "84ca122e-fcf1-4a84-89dc-b486d8f001b2",
      "name": "聚合摘要",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1344,
        -32
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "b2ca17b9-343c-4a90-99da-b0abcb54e492",
      "name": "基础LLM链",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        720,
        -32
      ],
      "parameters": {
        "text": "=Email Details:\n{{ $json.Subject }}\n{{ $json.From }}\nSnippet: {{ $json.Text }}\n\nClassify this email into one of the following:\nImportant, Ignore, Delegate, or Reply Later.\n\nRespond with only one word.",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are an intelligent email assistant trained to triage emails into four categories:\n\n1. Important – Action required soon or time-sensitive  \n2. Ignore – Irrelevant, spam, or low-priority  \n3. Delegate – Should be forwarded to someone else  \n4. Reply Later – Requires a thoughtful or delayed response  \n\nBe concise. Respond with **only one word**: Important, Ignore, Delegate, or Reply Later."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "2706328f-d171-429b-9352-b29dc493fb42",
      "name": "Azure OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        816,
        192
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "id": "C3WzT18XqF8OdVM6",
          "name": "Azure Open AI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "61f74b7f-dd74-44ab-bb31-8e460098d7a1",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -176,
        -32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bb021292-df71-4e01-a7de-2650a6444347",
      "name": "发送到 Notion",
      "type": "n8n-nodes-base.notion",
      "position": [
        1584,
        -32
      ],
      "parameters": {
        "title": "=Inbox Digest - {{ $now.format('D HH:mm') }} {{ $json.data[0].classification }}",
        "pageId": {
          "__rl": true,
          "mode": "url",
          "value": "https://www.notion.so/Welcome-to-Notion-248f839f1184803d9846ce0ace27c700"
        },
        "blockUi": {
          "blockValues": [
            {
              "textContent": "={{ $json.data[0].summary }}"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "notionApi": {
          "id": "zQhzvWiFBMYHHCj2",
          "name": "Notion account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "16aa3045-abeb-49c6-be2a-a2c9b802f92b",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        496,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b86137b4-b6f4-42f5-957d-a37ba2c5d056",
              "name": "Subject",
              "type": "string",
              "value": "={{ $json.headers.subject }}"
            },
            {
              "id": "33d19af9-5def-4fa2-8b8c-bcbec69bbb28",
              "name": "=From",
              "type": "string",
              "value": "={{ $json.headers.from }}"
            },
            {
              "id": "bc276088-30e2-4494-baae-93c810dc8002",
              "name": "=Text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1c75cd51-b5ce-43bf-88f0-d1bef310917a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -288
      ],
      "parameters": {
        "height": 256,
        "content": "🚀 工作流启动器"
      },
      "typeVersion": 1
    },
    {
      "id": "7e9c4c9f-3254-4e98-ad38-82a675926aaa",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        -416
      ],
      "parameters": {
        "color": 6,
        "height": 352,
        "content": "📊 洞察格式化器"
      },
      "typeVersion": 1
    },
    {
      "id": "779afae0-f16d-4478-8398-089da6229916",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -416
      ],
      "parameters": {
        "color": 5,
        "height": 368,
        "content": "🤖 AI 邮件分析器"
      },
      "typeVersion": 1
    },
    {
      "id": "b6ae2c79-b46d-425e-94b1-0583a11e244f",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        -400
      ],
      "parameters": {
        "color": 4,
        "height": 352,
        "content": "✏️ 数据结构优化器"
      },
      "typeVersion": 1
    },
    {
      "id": "e37b3942-dce1-4cd7-94fa-72daab915960",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -368
      ],
      "parameters": {
        "color": 3,
        "height": 320,
        "content": "🔄 邮件批处理器"
      },
      "typeVersion": 1
    },
    {
      "id": "fc4e9bbc-76fd-4d28-8834-b891f122a48d",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -368
      ],
      "parameters": {
        "color": 2,
        "height": 320,
        "content": "📧 邮件检索引擎"
      },
      "typeVersion": 1
    },
    {
      "id": "1aa60f5e-187d-42c9-b824-ea3478e42d1b",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        -416
      ],
      "parameters": {
        "color": 7,
        "height": 352,
        "content": "📈 智能整合器"
      },
      "typeVersion": 1
    },
    {
      "id": "a51c16db-0caa-47ad-b7df-0df25e1f7558",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        240
      ],
      "parameters": {
        "color": 5,
        "height": 368,
        "content": "🧠 企业级 AI 引擎"
      },
      "typeVersion": 1
    },
    {
      "id": "bb3b9be7-7154-4070-8616-c8a16c6e43f7",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1664,
        -416
      ],
      "parameters": {
        "color": 2,
        "height": 368,
        "content": "📝 知识库集成"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "026fe437-68d1-4647-9f04-9543c2e04a8d",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Emails": {
      "main": [
        [],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Summary": {
      "main": [
        [
          {
            "node": "Aggregate Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Notion": {
      "main": [
        [
          {
            "node": "Split Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Format Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Summary": {
      "main": [
        [
          {
            "node": "Send to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Unread Emails": {
      "main": [
        [
          {
            "node": "Split Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Unread Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 个人效率, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量18
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

外部链接
在 n8n.io 查看

分享此工作流