8
n8n 中文网amn8n.com

使用GPT-4o自动将Outlook邮件分类到颜色类别

中级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Set, ManualTrigger, SplitInBatches, Agent, MicrosoftOutlook 等节点。 使用GPT-4o自动将Outlook邮件分类到颜色类别

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "9ba14748-4bba-47d3-99d1-b9c4107f8a3a",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -416,
        4128
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d3a0b91a-00c7-4a6e-96a7-b82de25ed5fe",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1312,
        4000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f8ec514b-b64c-4bd5-bc86-91b24435cbf0",
      "name": "从 Outlook 获取邮件",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        -912,
        4384
      ],
      "webhookId": "b3f46aa6-f55c-420b-a444-7cd48f36f7f6",
      "parameters": {
        "limit": 5,
        "options": {},
        "operation": "getAll"
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "id": "9z1nG9ReKLXU309r",
          "name": "Microsoft Outlook account 4"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e072f4a2-0f5a-44ed-8e78-6f779f70a28b",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -256,
        4528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "4l6TDfLZVFS24g3X",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4670e0fa-82e2-483f-9891-83bc4f04f8be",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        64,
        4368
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"category\": \"Red Category, Yellow Category, or Green Category\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3e2d22a2-c1ba-48f7-bdff-855b1106365a",
      "name": "从邮件设置字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -592,
        3984
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "83f69529-de2b-4d4e-aac9-cd88e4336c94",
              "name": "subject",
              "type": "string",
              "value": "={{ $json.subject }}"
            },
            {
              "id": "af0befe4-5252-4fe4-9c0a-06e207e4c9a9",
              "name": "bodyPreview",
              "type": "string",
              "value": "={{ $json.bodyPreview }}"
            },
            {
              "id": "074a3879-8b0c-4601-a1d0-3284b69fbde2",
              "name": "from",
              "type": "string",
              "value": "={{ $json.from }}"
            },
            {
              "id": "02c201fc-996e-4777-b50e-10290da09262",
              "name": "Message ID",
              "type": "string",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3fd00d0a-fed9-4a36-9146-a826ebcdd633",
      "name": "分类代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -112,
        4112
      ],
      "parameters": {
        "text": "=body: {{ $json.bodyPreview }} subject: {{ $json.subject }}",
        "options": {
          "systemMessage": "You are a helpful assistant. take in the email message and determine if it is Red Category, Yellow Category, or Green Category. based on random\n\noutput data like this. \n\n{\n\t\"category\": \"Red Category, Yellow Category, or Green Category\"\n}\n\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "4a794da0-4294-4017-b7c7-59910e8f18d4",
      "name": "设置分类和ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -112,
        3920
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "85cc4512-3af8-400a-8814-2bdb75739321",
              "name": "output.category",
              "type": "string",
              "value": "={{ $json.output.category }}"
            },
            {
              "id": "d3fdc30b-9322-472c-b0ca-decb9cdd29bb",
              "name": "id",
              "type": "string",
              "value": "={{ $('Get Messages from Outlook').item.json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "27d99566-af49-42f3-808f-cafe530f6217",
      "name": "更新分类",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        144,
        3904
      ],
      "webhookId": "714959f9-3d6f-42d1-a93a-9b0db0c50950",
      "parameters": {
        "messageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "operation": "update",
        "updateFields": {
          "categories": "={{ [$json.output.category] }}"
        }
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "id": "9z1nG9ReKLXU309r",
          "name": "Microsoft Outlook account 4"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f25951d2-935a-4b7b-b00b-53f08a82513a",
      "name": "便签54",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        4336
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 304,
        "content": "### 2️⃣ 设置 OpenAI 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "4fb6ac63-881f-4740-8abc-404ac65d093a",
      "name": "便签24",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        4160
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 336,
        "content": "### 2️⃣ 设置 Outlook 连接"
      },
      "typeVersion": 1
    },
    {
      "id": "c4449b1f-301c-4a6a-b7d8-56d65f20911c",
      "name": "便签21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1888,
        3792
      ],
      "parameters": {
        "width": 400,
        "height": 928,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "1f45d710-c178-48de-baf3-6da87661b64e",
      "name": "便利贴22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        3792
      ],
      "parameters": {
        "color": 7,
        "width": 1936,
        "height": 928,
        "content": "# 📧 使用 OpenAI 自动分类 Outlook 邮件 (n8n)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Set Category and ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Categorizing Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Categorizing Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Categorizing Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Category and ID": {
      "main": [
        [
          {
            "node": "Update Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Fields from Email": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Categorizing Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Messages from Outlook": {
      "main": [
        [
          {
            "node": "Set Fields from Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Messages from Outlook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - AI 摘要总结, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流