我的工作流

中级

这是一个AI Summarization、Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 If、Set、Gmail、SplitInBatches、Agent 等节点。 整理 Gmail:使用 GPT-4 分类归档非活跃邮件

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "我的工作流",
  "nodes": [
    {
      "id": "7e91ccc0-03e5-4989-8c3f-d3635313f393",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -864,
        368
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 2
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "eea7bc1f-c4a4-4c2d-bd6f-27f977948e32",
      "name": "列出旧收件箱邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -640,
        368
      ],
      "webhookId": "a77f2f37-91b8-44e1-9d9e-7a58136627c0",
      "parameters": {
        "simple": false,
        "filters": {
          "q": "label:inbox older_than:45d",
          "labelIds": [
            "INBOX"
          ],
          "readStatus": "read"
        },
        "options": {},
        "operation": "getAll",
        "returnAll": true
      },
      "typeVersion": 2.1,
      "alwaysOutputData": false
    },
    {
      "id": "d88c4116-55e9-48b8-ae1f-9d89cc39bd99",
      "name": "为 AI 准备邮件",
      "type": "n8n-nodes-base.set",
      "position": [
        -192,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5d3c4c5b-5f80-4340-82ca-fb584a1fc953",
              "name": "threadId",
              "type": "string",
              "value": "={{ $json.threadId }}"
            },
            {
              "id": "a33a5a8a-dc7a-4fed-9262-8c6d10434128",
              "name": "messageId",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "c982f401-ce58-4d5e-ba30-a13d03971705",
              "name": "Subject",
              "type": "string",
              "value": "={{ $json.subject }}"
            },
            {
              "id": "c18cd58e-407a-48a4-b9e1-5877a1f90df4",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "57e6c6b6-fe9a-49ff-aac6-3687bdb3b236",
      "name": "遍历邮件",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -416,
        368
      ],
      "parameters": {
        "options": {},
        "batchSize": 50
      },
      "typeVersion": 3
    },
    {
      "id": "3dab757d-460d-4935-a6bc-10e761072575",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        32,
        240
      ],
      "parameters": {
        "text": "=You are an assistant classifying Gmail emails. Output JSON only, no prose.\n\nOnly use these inputs:\nthreadId: {{ $json.threadId }}\nmessageId: {{ $json.messageId }}\nsubject: {{ $json.subject }}\ntext: {{ $json.text }}\n\nAssume today's date is {{ $now.toFormat('yyyy-LL-dd') }}.\n\nTasks:\n1) Extract a due date from the text if present, format YYYY-MM-DD. If none, use null.\n2) Decide if the email requires action. Action means at least one of:\n   - It is an invoice or bill that expects payment\n   - It explicitly requests a reply or a decision\n   - It clearly contains a task or meeting to schedule\n3) Set trashable = true if any of these are true:\n   - due_date is null\n   - due_date is earlier than today\n   - requires_action is false\n   Otherwise trashable = false.\n\nReturn JSON with this exact structure:\n{\n  \"threadId\": \"<string>\",\n  \"messageId\": \"<string>\",\n  \"requires_action\": true | false,\n  \"due_date\": \"YYYY-MM-DD\" | null,\n  \"trashable\": true | false,\n  \"reason\": \"<short explanation>\"\n}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "54867a18-8d2b-4697-92ed-b01c53cb322c",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        48,
        464
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "20193ea2-1b6d-428b-9219-160ffab88242",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        176,
        464
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"title\": \"SimpleEmailTriage\",\n  \"type\": \"object\",\n  \"required\": [\"threadId\", \"messageId\", \"requires_action\", \"due_date\", \"trashable\", \"reason\"],\n  \"properties\": {\n    \"threadId\": { \"type\": \"string\" },\n    \"messageId\": { \"type\": \"string\" },\n    \"requires_action\": { \"type\": \"boolean\" },\n    \"due_date\": { \"type\": [\"string\", \"null\"], \"pattern\": \"^\\\\d{4}-\\\\d{2}-\\\\d{2}$\" },\n    \"trashable\": { \"type\": \"boolean\" },\n    \"reason\": { \"type\": \"string\" }\n  },\n  \"additionalProperties\": false\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "2495ccbf-8a5b-4cc3-bce3-6d961616dc16",
      "name": "已完成",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -192,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e7a26dcc-ded8-4d74-8fff-19942a46c5cc",
      "name": "如果 - 应归档?",
      "type": "n8n-nodes-base.if",
      "position": [
        384,
        368
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7426c831-e458-48fe-80ef-5b2fe11c897c",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.trashable }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c9824337-668f-490b-a32c-0e10c6ebe7db",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 304,
        "height": 608,
        "content": "### 🧠 AI 邮件分类器"
      },
      "typeVersion": 1
    },
    {
      "id": "5a40520c-0d16-442f-a9ef-d13ca97d204d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        112
      ],
      "parameters": {
        "color": 5,
        "height": 416,
        "content": "### 📥 Gmail:列出旧邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "0672da9a-b5bb-4709-ac87-99ddb56632cd",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        112
      ],
      "parameters": {
        "color": 5,
        "height": 416,
        "content": "### 📆 安排工作流程"
      },
      "typeVersion": 1
    },
    {
      "id": "ef9dfef6-9d58-4d49-9bc6-407bd4853b35",
      "name": "归档邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        608,
        448
      ],
      "webhookId": "eeb7c097-a237-4d0f-98bc-ae823c89822b",
      "parameters": {
        "labelIds": [
          "INBOX"
        ],
        "resource": "thread",
        "threadId": "={{ $json.output.threadId }}",
        "operation": "removeLabels"
      },
      "typeVersion": 2.1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "If - Should archived?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Archive Email": {
      "main": [
        [
          {
            "node": "Loop Over Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Emails": {
      "main": [
        [
          {
            "node": "Completed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prep Email for AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "List old inbox emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prep Email for AI": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Should archived?": {
      "main": [
        [
          {
            "node": "Archive Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List old inbox emails": {
      "main": [
        [
          {
            "node": "Loop Over Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个中级难度的工作流,适用于AI Summarization、Multimodal AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

需要付费吗?

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

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

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

作者
Matt Chong | n8n Creator

Matt Chong | n8n Creator

@mattxchong

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

外部链接
在 n8n.io 上查看 →

分享此工作流