8
n8n 中文网amn8n.com

基于OpenAI GPT-4分类的Gmail邮件自动分类与标记

中级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Gmail, SplitInBatches, ScheduleTrigger, LmChatOpenAi, TextClassifier 等节点。 基于OpenAI GPT-4分类的Gmail邮件自动分类与标记

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "434e0315-d478-4fc6-9d68-b6d83692d56d",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -220,
        -60
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9a3551be-1e97-4b1a-986e-55adb27ea660",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        220,
        -40
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "e44d7114-2e55-4bc3-82d6-b9fdf10651d8",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        440,
        180
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "MGwGMKEkdcjzlYCw",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "123cb1eb-0d71-4e61-a4af-f514c54f20e2",
      "name": "添加标签 (高优先级)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        940,
        -200
      ],
      "webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
      "parameters": {
        "labelIds": [
          "IMPORTANT"
        ],
        "resource": "thread",
        "threadId": "={{ $json.threadId }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "CeBpTZBQSAMKVKJY",
          "name": "Gmail account (Billy Email 2)"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e1b53e1d-da8d-483d-8fe3-ddc821b66c0e",
      "name": "添加标签 (个人)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        940,
        0
      ],
      "webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
      "parameters": {
        "labelIds": [
          "CATEGORY_PERSONAL"
        ],
        "resource": "thread",
        "threadId": "={{ $json.threadId }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "CeBpTZBQSAMKVKJY",
          "name": "Gmail account (Billy Email 2)"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "711c5194-4046-42ac-8e2e-acbe2026ac29",
      "name": "添加标签 (推广)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        940,
        220
      ],
      "webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
      "parameters": {
        "labelIds": [
          "CATEGORY_PROMOTIONS"
        ],
        "resource": "thread",
        "threadId": "={{ $json.threadId }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "CeBpTZBQSAMKVKJY",
          "name": "Gmail account (Billy Email 2)"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ac4c736c-4948-4463-9651-54e1b5e592fa",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 300,
        "content": "## 需要设置"
      },
      "typeVersion": 1
    },
    {
      "id": "29a5312e-4ddf-41e7-afff-1e8683feca28",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        500
      ],
      "parameters": {
        "color": 4,
        "width": 680,
        "height": 400,
        "content": "## 📋 工作流流程概览"
      },
      "typeVersion": 1
    },
    {
      "id": "8825d969-1365-4c33-bc00-e995deb40e64",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        200
      ],
      "parameters": {
        "color": 4,
        "width": 680,
        "height": 280,
        "content": "## 📧 智能 Gmail 标签自动化与文本分类器和 GPT-5"
      },
      "typeVersion": 1
    },
    {
      "id": "6ab81542-c082-409a-affd-138e766d42a9",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        -380
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 860,
        "content": "## 添加标签节点"
      },
      "typeVersion": 1
    },
    {
      "id": "e6ef7d72-00a6-457d-8059-f20dcecc9d9f",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -180
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 320,
        "content": "## 标签分类器"
      },
      "typeVersion": 1
    },
    {
      "id": "ce7c17d4-958e-4d77-8b99-07d71b1005a0",
      "name": "标签分类器",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        460,
        0
      ],
      "parameters": {
        "options": {
          "fallback": "other"
        },
        "inputText": "=Email Subject:\n{{ $json.headers.subject }}\n\nEmail Body:\n{{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "High Priority",
              "description": "Emails that require immediate attention or urgent action."
            },
            {
              "category": "Personal",
              "description": "Personal refers to activities or matters related to private life, self, or non-work interests."
            },
            {
              "category": "Promotions",
              "description": "Promotions refer to marketing messages or activities that advertise products, services, or offers"
            }
          ]
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": false
    },
    {
      "id": "1c81d787-784f-48bb-bdd2-2b9b2f9fc975",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -220
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 320,
        "content": "## Gmail - 获取邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "9482f1e2-d564-4f15-938e-d4db4b1a59cb",
      "name": "Gmail - 获取邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -20,
        -60
      ],
      "webhookId": "9777ca5f-5226-4fc8-b93b-a3344f890dd3",
      "parameters": {
        "limit": 10,
        "simple": false,
        "filters": {
          "receivedAfter": "={{ $now.minus({ minutes: 50000 }).toMillis() }}"
        },
        "options": {},
        "operation": "getAll"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "CeBpTZBQSAMKVKJY",
          "name": "Gmail account (Billy Email 2)"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "pinData": {},
  "connections": {
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Label Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label Classifier": {
      "main": [
        [
          {
            "node": "Add Label (High Priority)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Label (Personal)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Label (Promotions)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Gmail - Get Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Label Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Get Emails": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Label (Personal)": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Label (Promotions)": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Label (High Priority)": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Billy Christi

Billy Christi

@billy

I build scalable automation systems with n8n to help businesses save time and cut costs. 💼 n8n expert available for new projects 📩 billychartanto@gmail.com

外部链接
在 n8n.io 查看

分享此工作流