8
n8n 中文网amn8n.com

使用Gemini AI和Google Workspace将每日邮件和日历摘要发送到Slack

高级

这是一个Miscellaneous, AI Summarization, Multimodal AI领域的自动化工作流,包含 20 个节点。主要使用 Code, Cron, Gmail, Merge, Slack 等节点。 使用Gemini AI和Google Workspace将每日邮件和日历摘要发送到Slack

前置要求
  • Google 账号和 Gmail API 凭证
  • Slack Bot Token 或 Webhook URL
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "86qWVU9iA1LQM3pC",
  "meta": {
    "instanceId": "bbc3fa3cd7d64d8ff0c4877d98dee68ce7dadacc5e089546680c915b3e5a212b"
  },
  "name": "使用Gemini AI和Google Workspace将每日邮件和日历摘要发送到Slack",
  "tags": [],
  "nodes": [
    {
      "id": "766a5fc5-00d7-4874-ac0d-c3727476a708",
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1216,
        -96
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 8
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "83f5136b-f441-4419-b31e-9c7e31705777",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        576,
        -176
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "4339797c-3b99-41a2-b66d-d41b604a7efc",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        576,
        256
      ],
      "parameters": {
        "text": "=You are an assistant that summarizes calendar data clearly.  \n\n### Task\n1. Summarize the calendar events.  \n   - Use the format: [Date | Time] → [Event Title] – [Short Notes/Details].  \n\n### Formatting Rules\n- Each summary should be on a new line with no markdown symbols.  \n- Maximum of 5 sentences and minimum of 1 sentence.  \n- Add a prefix and suffix star for the heading Calendar.  \n- Do not include links in the emails.  \n\nSummary:  \n\n### Example Output\n*Calendar Summary:*  \n2025-08-26 | 10:00 AM - 10:30 AM → Team Standup – Daily sync-up  \n2025-08-26 | 12:00 PM - 12:30 PM → Team Standup – n8n meeting  ",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "44707b49-2c51-4295-b1b5-431199ceacc9",
      "name": "在Google日历中获取多个事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        688,
        448
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{$today.plus({days: 1}).toISO()}}",
        "timeMin": "={{$today.toISO()}}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "operation": "getAll"
      },
      "typeVersion": 1.3
    },
    {
      "id": "cee7ac7f-54ef-4240-a87f-755ae7bc8407",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        640,
        -336
      ],
      "parameters": {
        "text": "=You are an assistant that summarizes email messages from the provided JSON array {{ $json.text }}.\n\nInstructions:\n- For each email in the array, generate a summary in exactly 3 sentences.\n- Each summary must include:\n   • Sender (from the \"{{ $json.from.value[0].name }}\" field)\n   • Subject (from the \"{{ $json.subject }}\" field)\n   • Brief summary of the \"{{ $json.text }}\" content  \n- Do not use bullet points or markdown.  \n- Keep the tone professional and concise, suitable for sending to Slack.  \n- Output summaries one after another, separated by a blank line.\n- Send this as Json\n{\n\"from\":\"[sender email]\"\n\"subject\": \"[subject line]\"\n\"summary\":\"[3 sentence summary]\"\n}\n\n\nDon't use \\n should send in a format that can parse as json using JavaScript or Python",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7cd241f5-05b8-4fcd-a0fb-941a1db50c78",
      "name": "获取每周未读邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -720,
        -336
      ],
      "webhookId": "26acee9e-eb01-479e-812d-44974d9430dc",
      "parameters": {
        "limit": 100,
        "simple": false,
        "filters": {
          "labelIds": [
            "INBOX"
          ],
          "readStatus": "unread",
          "receivedAfter": "={{ $today.minus({ days: 7 }).toISODate() }}"
        },
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "id": "bcd7209d-94a7-4fbb-9b3c-dc54d6572cc3",
      "name": "获取姓名、邮件和主题",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -464,
        -336
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        }
      },
      "executeOnce": true,
      "typeVersion": 4.7
    },
    {
      "id": "783b5790-812d-4688-9a49-b8e7f77ae24c",
      "name": "重构电子表格中的数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -48,
        -336
      ],
      "parameters": {
        "jsCode": "const items = $input.all().map(i => i.json);\n\nconst result = {\n  emails: [],\n  name: [],\n  subjects: []\n};\n\nfor (const row of items) {\n  if (row.Email && row.Email.trim() !== \"\") {\n    result.emails.push(row.Email);\n  }\n  if (row.Name && row.Name.trim() !== \"\") {\n    result.name.push(row.Name);\n  }\n  if (row.Subject && row.Subject.trim() !== \"\") {\n    result.subjects.push(row.Subject);\n  }\n}\n\n// Return as array of one item\nreturn [{ json: result }];\n"
      },
      "executeOnce": true,
      "typeVersion": 2
    },
    {
      "id": "1bc739a9-0082-417a-b60e-88069bc2742c",
      "name": "过滤邮件",
      "type": "n8n-nodes-base.code",
      "position": [
        208,
        -336
      ],
      "parameters": {
        "jsCode": "const emails = $input.first().json.emails;   // list of blocked emails\nconst subjects = $input.first().json.subjects;\nconst names = $input.first().json.name;// list of blocked subjects\n\nreturn $('Get weekly unread emails').all().filter(item => {\n  const email = item.json.from.value[0].address;  \n  const subject = item.json.subject;  \n  const name = item.json.from.value[0].name; \n\n  return emails.includes(email) || subjects.includes(subject) ||names.includes(name) ;\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "a809c2be-4563-48fe-b096-2126d67dbde0",
      "name": "重构来自AI代理的代码",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        -336
      ],
      "parameters": {
        "jsCode": "// Get all input items\nlet items = $input.all();\n\n// Initialize Slack blocks\nlet blocks = [];\n\nfor (let item of items) {\n  let raw = item.json.output; // raw string with ```json ... ```\n\n  // Clean backticks and parse\n  let cleaned = raw.replace(/```json\\n?/, \"\").replace(/```$/, \"\");\n  let parsed = JSON.parse(cleaned);\n\n  // Add Slack blocks\n  blocks.push({ type: \"divider\" });\n  blocks.push({\n    type: \"section\",\n    text: {\n      type: \"mrkdwn\",\n      text: `*${parsed.from}*\\n*${parsed.subject}*\\n${parsed.summary}`\n    }\n  });\n}\n\n// Return one Slack message with all blocks\nreturn [\n  {\n    json: {\n      blocks: blocks\n    }\n  }\n];\n"
      },
      "executeOnce": false,
      "typeVersion": 2
    },
    {
      "id": "20bd2254-88a0-4238-ad91-fcd6708b9def",
      "name": "重构来自AI代理的代码",
      "type": "n8n-nodes-base.code",
      "position": [
        992,
        256
      ],
      "parameters": {
        "jsCode": "// Get all input items\nlet items = $input.all();\n\n// Initialize Slack blocks\nlet blocks = [];\n\nfor (let item of items) {\n  let text = item.json.output;\n\n  blocks.push({ type: \"divider\" });\n  blocks.push({\n    type: \"section\",\n    text: {\n      type: \"mrkdwn\",\n      text: `${text}`\n    }\n  });\n}\n\nreturn [\n  {\n    json: {\n      blocks: blocks\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e6c0ad9c-0da5-4e59-bfdf-7f8381e1f241",
      "name": "附加邮件和事件",
      "type": "n8n-nodes-base.merge",
      "position": [
        1552,
        -48
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "9ad25b6a-fe2e-487c-a232-bdd36585ae8b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        -432
      ],
      "parameters": {
        "color": 3,
        "width": 544,
        "height": 288,
        "content": "## 获取过去一周的未读邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "50ae9ce1-1bc5-42bd-bbe0-a16fd1c513d0",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -480
      ],
      "parameters": {
        "width": 576,
        "height": 336,
        "content": "## 基于姓名、邮件、主题过滤邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "0fe896b9-abe0-4134-b285-838206b9bb37",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -480
      ],
      "parameters": {
        "width": 608,
        "height": 464,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "2a4fe129-be9f-4e12-8379-ca6ba058e9e9",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        80
      ],
      "parameters": {
        "color": 4,
        "width": 704,
        "height": 496,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "57547082-e53f-4372-8f48-24dba3f768bf",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -224
      ],
      "parameters": {
        "color": 6,
        "width": 688,
        "height": 400,
        "content": "## 将事件摘要和邮件摘要发送到Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "b595b001-08cf-4497-a5aa-afd3bba4d496",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1824,
        -928
      ],
      "parameters": {
        "width": 592,
        "height": 576,
        "content": "## 📩 每日邮件 & 🗓️ 日历摘要 → 📢 Slack通知系统"
      },
      "typeVersion": 1
    },
    {
      "id": "09162e4b-5d61-420b-a906-475ab749f6e3",
      "name": "发送消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        1952,
        -48
      ],
      "webhookId": "b0de3b56-3196-4d08-bfe7-b90db5a2ac9a",
      "parameters": {
        "select": "channel",
        "blocksUi": "={{ '{ \"blocks\": ' + JSON.stringify($json.blocks) + ' }' }}",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "messageType": "block",
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "20be74e9-31be-44f9-aca9-28db494ea197",
      "name": "将代码重构为Slack块",
      "type": "n8n-nodes-base.code",
      "position": [
        1760,
        -48
      ],
      "parameters": {
        "jsCode": "const allInputs = $input.all();\n\nconst mergedBlocks = allInputs.flatMap(item => item.json.blocks || []);\n\nreturn {\n  json: {\n    blocks: mergedBlocks\n  }\n};\n"
      },
      "executeOnce": false,
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5e78ad2b-6bb6-4432-b4ce-59cd0fa02804",
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Get weekly unread emails",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Restructure the code from AI agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Restructure the code from the AI agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter the emails": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append mails and events ": {
      "main": [
        [
          {
            "node": "Restructure the code into slack block",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get weekly unread emails": {
      "main": [
        [
          {
            "node": "Get Names, emails and subject",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Names, emails and subject": {
      "main": [
        [
          {
            "node": "Restructure the data from spread sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many events in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Restructure the code from AI agent": {
      "main": [
        [
          {
            "node": "Append mails and events ",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Restructure the code into slack block": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Restructure the code from the AI agent": {
      "main": [
        [
          {
            "node": "Append mails and events ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Restructure the data from spread sheet": {
      "main": [
        [
          {
            "node": "Filter the emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 杂项, AI 摘要总结, 多模态 AI

需要付费吗?

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

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

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

作者
Sayone Technologies

Sayone Technologies

@sayonetech

SayOne Technologies is a digital transformation and IT services company headquartered in India, with a strong focus on web, mobile, and AI-driven solutions for the retail tech space. With over a decade of experience, SayOne partners with global businesses to build scalable applications, optimize inventory and operations using next-gen AI, and deliver customer-centric digital products.

外部链接
在 n8n.io 查看

分享此工作流