8
n8n 中文网amn8n.com

带有 AI 摘要的每日邮件摘要

高级

这是一个Personal Productivity, AI Summarization领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Code, Gmail, ScheduleTrigger 等节点。 使用 OpenAI O4-Mini 从 Gmail 标签创建 AI 摘要的邮件摘要

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": ""
  },
  "name": "带有 AI 摘要的每日邮件摘要",
  "tags": [],
  "nodes": [
    {
      "id": "6e739c6d-8fe0-46ba-9f92-c88adff879cf",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        -260,
        440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c772f463-4fe1-4e8f-8cac-d9c1dec71f03",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{$items().length}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "572ca84c-f3b8-478d-aa51-4d63ae462671",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -40,
        260
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "o4-mini",
          "cachedResultName": "o4-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "8f6dafea-8cf6-47d5-b117-58f748de860e",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        80,
        280
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $json.text }}",
        "jsonMode": "expressionData",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ae79599f-c03c-4ca3-a074-89348c1d7d4e",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        180,
        460
      ],
      "parameters": {
        "options": {},
        "chunkSize": "={{ $json.text.length }}"
      },
      "typeVersion": 1
    },
    {
      "id": "646ced0e-cd43-449b-917c-bd376b748c15",
      "name": "无操作,不执行任何操作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        40,
        660
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d7c20f5e-f388-474a-975b-413292a1ad60",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        460,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "165006bf-ec9c-4f7b-a840-28486ce1dba3",
              "name": "output.text",
              "type": "string",
              "value": "={{ $json.output.text }}"
            },
            {
              "id": "94bb7c0a-210a-484f-b363-3960cce119f2",
              "name": "subject",
              "type": "string",
              "value": "={{ $('Get mails (last 24h)').item.json.subject }}"
            },
            {
              "id": "30f4fd53-3c46-4e6c-8852-7fedb2a32301",
              "name": "headers.from",
              "type": "string",
              "value": "={{ $('If').item.json.headers.from }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7681c2c6-ccbc-4675-8f5d-9ebfe52e1788",
      "name": "合并主题和正文",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        240
      ],
      "parameters": {
        "jsCode": "// Combine all items into one content block\nlet allContent = '';\n\n\n\nfor (const item of $input.all()) {\n  const originalFrom = `${item.json.headers.from}`;\n  const fromPrefix = \"From: \";\n  let trancatedFrom;\n  \n  if (originalFrom.startsWith(fromPrefix)) {\n    trancatedFrom = originalFrom.substring(fromPrefix.length);\n  } else {\n    trancatedFrom = originalFrom;\n  }\n  // Create H2 heading from subject\n  const heading = `<h3>${item.json.subject} [${trancatedFrom}]</h3>`;\n  \n  // Add heading and body to combined content\n  allContent += heading + `\\n\\n${item.json.output.text}\\n\\n`;\n}\n\n// Return a single item with all combined content\nreturn [{\n  json: {\n    combinedContent: allContent.trim(),\n    itemCount: $input.all().length\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "b39f8459-49b0-47e9-8848-71d76aac8149",
      "name": "邮件摘要",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        -20,
        40
      ],
      "parameters": {
        "options": {
          "summarizationMethodAndPrompts": {
            "values": {
              "prompt": "Write a concise summary of the following email digest.\n- If the digest includes multiple topics, summarize each topic as a separate bullet point.\n- If the digest refers to external links for a topic preserve them and insert at appropriated places inside summorized text under ascending numbers ([1], [2], etc.).\n- Format the output as HTML, using <p> tags for paragraphs and <ul><li> for bullet points and <a href> for external links.\n- Reply directly with the summorized text.\n\nExample:\n<ul>\\n  <li>\\n    <p>Meta has recruited Apple's head of AI models, Ruoming Pang<a href=\"https://techcrunch.com/2025/07/07/meta-reportedly-recruits-apples-head-of-ai-models/\">[1]</a>, suggesting an intensifying talent war and possible work on its next-gen AI glasses<a href=\"https://www.androidauthority.com/meta-hypernova-smart-glasses-leaked-render-3572798/\">[2]</a>.</p>\\n  </li>\\n  <li>\\n    <p>Key AI headlines: Chinese firms ramp up; Samsung forecasts a 56% profit drop amid weak AI chip demand<a href=\"https://www.cnbc.com/2025/07/08/samsung-projects-second-quarter-profits-drop-56-percent-struggles-ai-demand-nvidia-sk-hynix-micron.html\">[3]</a>; Cursor blames costly models for business woes<a href=\"https://techcrunch.com/2025/07/07/cursor-apologizes-for-unclear-pricing-changes-that-upset-users/\">[4]</a>; CoreWeave to buy Core Scientific for $9 billion<a href=\"https://www.bloomberg.com/news/articles/2025-07-07/coreweave-to-buy-core-scientific-in-deal-valued-at-9-billion\">[5]</a>.\n\nDigest to summorize.\n\"{text}\"\n\nSUMMARY:",
              "summarizationMethod": "stuff"
            }
          }
        },
        "operationMode": "documentLoader"
      },
      "typeVersion": 2.1
    },
    {
      "id": "5176a79f-2d9b-43c9-a20a-819e60bda044",
      "name": "发送摘要邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        900,
        240
      ],
      "parameters": {
        "sendTo": "your-email@example.com",
        "message": "={{ $json.combinedContent }}",
        "options": {},
        "subject": "=Daily Tech-News Digest for {{ $now.toISODate() }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "67798876-7912-4597-9959-000bf8f870af",
      "name": "获取邮件(最近 24 小时)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -480,
        440
      ],
      "parameters": {
        "limit": 20,
        "simple": false,
        "filters": {
          "labelIds": [
            "YOUR_LABEL_ID"
          ],
          "receivedAfter": "={{$now.minus({days: 1}).toISO()}}"
        },
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "id": "de4aab88-76ea-4688-8385-47406e01c2e5",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -680,
        440
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d45213a8-e076-48ac-8593-55a12ec18245",
      "name": "主工作流说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        0
      ],
      "parameters": {
        "width": 460,
        "height": 800,
        "content": "## 带有 AI 摘要的每日邮件摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "4bfbdef6-39fd-464e-9ccf-1d1bd71e2372",
      "name": "邮件检索部分",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        580
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 300,
        "content": "## 1. 定时邮件检索"
      },
      "typeVersion": 1
    },
    {
      "id": "290e0ef6-60a0-4f0a-8040-31ed41a91af8",
      "name": "AI 处理部分",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -260
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 360,
        "content": "## 2. AI 驱动的邮件摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "4a78b0ba-cdea-4da8-9929-a955eafbefa5",
      "name": "格式化和输出部分",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 580,
        "height": 700,
        "content": "## 3. 内容格式化和邮件发送"
      },
      "typeVersion": 1
    },
    {
      "id": "75c6d291-083b-416d-b8fa-ecfe24b875d7",
      "name": "条件处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        580
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 200,
        "content": "## 智能处理"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Summarization Mails",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Combine Subject and Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get mails (last 24h)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarization Mails",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Summarization Mails",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Summarization Mails": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get mails (last 24h)": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Subject and Body": {
      "main": [
        [
          {
            "node": "Send Digested mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 个人效率, AI 摘要总结

需要付费吗?

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

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

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

作者
German Velibekov

German Velibekov

@germanv

Passionate about building intelligent systems and scalable infrastructure.

外部链接
在 n8n.io 查看

分享此工作流