8
n8n 中文网amn8n.com

使用AI汇总MS Teams频道活动生成周报

高级

这是一个Other, HR, AI, IT Ops领域的自动化工作流,包含 17 个节点。主要使用 Set, Code, Markdown, SplitOut, Aggregate 等节点,结合人工智能技术实现智能自动化。 使用AI汇总MS Teams频道活动生成周报

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ee39f797-6f6f-4a62-9cf1-0c95b47baf23",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -160,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c1b9fadc-586b-4edf-a19a-6995479d4de5",
      "name": "获取最新频道消息",
      "type": "n8n-nodes-base.microsoftTeams",
      "position": [
        60,
        0
      ],
      "webhookId": "b36a534a-1bca-4c3d-ab25-777ca98fba1a",
      "parameters": {
        "teamId": {
          "__rl": true,
          "mode": "id",
          "value": "=fc62d6a3-eaba-430f-b451-3c3107751ba0"
        },
        "resource": "channelMessage",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "=19:NQuQMYvvtC9DcTEQs1Vul1Nm1xIXnRmznAwov7MuNZ81@thread.tacv2"
        },
        "operation": "getAll"
      },
      "credentials": {
        "microsoftTeamsOAuth2Api": {
          "id": "AUH9lDgO5KTl2J6q",
          "name": "Microsoft Teams account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1be03962-5028-47a8-8deb-3c59c121df01",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        920,
        140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "04a75b1c-685f-4264-ade7-cb2778fc7d4f",
      "name": "团队成员周报代理",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        820,
        0
      ],
      "parameters": {
        "text": "=## User\nDisplayName: {{ $json.user.displayName }}\n\n## Messages\n{{\nArray.from($json.messages)\n.map(msg => {\n  return [\n    `Type: Message`,\n    `Posted: ${msg.createdDateTime}`,\n    `Message: ${msg.body.content.replaceAll('\\n', ' ')}`,\n    msg.parent ? `In Reply To: ${msg.parent.from.user.displayName} said \"${msg.parent.body.content.replace('\\n', ' ')}\"` : ''\n  ].join('\\n')\n}).join('---\\n')\n}}",
        "messages": {
          "messageValues": [
            {
              "message": "=Your are energetic assistant who produces weekly mini-reports on team members by analysing their slack messages from last week and posts these reports on the following Monday.\nThere has already been some work done to collect and summarise each thread made by the user within the last week.\nYour task is to summarize all the threads by this user and any interactions with other users involved and produce a mini report to share with other team members.\nFocus on wins and challenges.\nAim to motivate and call out any outstanding concerns where appropriate.\nWelcome any new team members who may have joined and say good bye to those who may have left."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "919347aa-cd48-42ff-9504-dd66c5b18caa",
      "name": "将报告与用户数据合并",
      "type": "n8n-nodes-base.set",
      "position": [
        1200,
        0
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{\n{\n  ...$('Groups to Items').item.json,\n  report: $json.text\n}\n}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "67c23cf0-9af6-4a89-94c0-7a3e01230b2f",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1820,
        140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "65111f1b-42c7-4657-9512-e740d75bdbdc",
      "name": "报告合并为单一列表",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1500,
        0
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "82a90342-cc4d-4d80-9ff6-83cab22861f4",
      "name": "团队周报代理",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1720,
        0
      ],
      "parameters": {
        "text": "={{\n$input.first().json.data\n  .map(item =>\n`user: ${item.user.displayName} <${item.user.id}>\nmessage count: ${item.messages.length}\nreport: ${item.report.replaceAll('\\n', ' ')}`\n  )\n  .join('\\n---\\n')\n}}",
        "messages": {
          "messageValues": [
            {
              "message": "=Your are energetic assistant who produces a team-wide weekly report from all activity of all team members in the prior last week and posts this single report on the following Monday.\nThere has already been some work done to collect individual reports from team members.\nYour task is generate a report covering the team to prepare and motivate them for the upcoming week.\nFocus on wins and challenges if available.\nLook out for similar activities between members and make a connection if possible.\nAim to motivate and call out any outstanding concerns where appropriate.\nWelcome any new team members who may have joined and say good bye to those who may have left.\nFormat the report as markdown.\nDo not sign off on the report."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "464a925f-eb06-4b59-a262-ca336506de15",
      "name": "Markdown 转 HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        2300,
        0
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {},
        "markdown": "={{ $json.text }}",
        "destinationKey": "html"
      },
      "typeVersion": 1
    },
    {
      "id": "ecb047a7-5d52-4e87-8d0e-c9c17489cddc",
      "name": "将报告发送到频道",
      "type": "n8n-nodes-base.microsoftTeams",
      "position": [
        2540,
        0
      ],
      "webhookId": "b36a534a-1bca-4c3d-ab25-777ca98fba1a",
      "parameters": {
        "teamId": {
          "__rl": true,
          "mode": "id",
          "value": "=fc62d6a3-eaba-430f-b451-3c3107751ba0",
          "__regex": "^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})"
        },
        "message": "={{ $json.html }}",
        "options": {
          "includeLinkToWorkflow": false
        },
        "resource": "channelMessage",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "=19:NQuQMYvvtC9DcTEQs1Vul1Nm1xIXnRmznAwov7MuNZ81@thread.tacv2"
        },
        "contentType": "html"
      },
      "credentials": {
        "microsoftTeamsOAuth2Api": {
          "id": "AUH9lDgO5KTl2J6q",
          "name": "Microsoft Teams account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e1d371c8-9069-4a33-a450-78055769931b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 540,
        "content": "## 1. 获取上周所有频道消息"
      },
      "typeVersion": 1
    },
    {
      "id": "77aff845-5226-4023-a2da-afb2021a08ed",
      "name": "按用户 ID 分组消息",
      "type": "n8n-nodes-base.code",
      "position": [
        280,
        0
      ],
      "parameters": {
        "jsCode": "const messages = $input.all().map(item => item.json);\n\nconst groupByUserId = messages.reduce((acc,msg) => {\n  return {\n    ...acc,\n    [msg.from.user.id]: acc[msg.from.user.id]\n      ? acc[msg.from.user.id].concat(msg)\n      : [msg]\n  }\n}, {});\n\nconst output = Object.keys(groupByUserId).map(userId => {\n  const userMessages = groupByUserId[userId];\n  for (let i=0,j=userMessages.length;i<j;i++) {\n    if (userMessages[i].replyToId) {\n      userMessages[i].parent = messages.find(msg => msg.id === userMessages[i].replyToId);\n    }\n  }\n  return {\n    user: userMessages[0].from.user,\n    messages: userMessages\n  };\n});\n\nreturn { output };"
      },
      "typeVersion": 2
    },
    {
      "id": "ee415463-a7e2-43dd-abfa-4050cc230452",
      "name": "分组转为项目",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        600,
        0
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "8d4c7621-3c04-4fbe-bbee-b7dade2ab837",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 540,
        "content": "## 2. 为每位团队成员生成活动报告"
      },
      "typeVersion": 1
    },
    {
      "id": "22f3e375-201d-4a66-b1e0-592bbeb12eac",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 540,
        "content": "## 3. 为整个团队生成最终报告"
      },
      "typeVersion": 1
    },
    {
      "id": "873c2510-cf01-464b-b84e-936bd1c4d7a7",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2140,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 540,
        "content": "## 4. 在团队频道上发布报告(周一早上!)"
      },
      "typeVersion": 1
    },
    {
      "id": "4882c210-fec8-4b8e-b114-0b6d889ed917",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -960
      ],
      "parameters": {
        "width": 420,
        "height": 1400,
        "content": "## 试试看!"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Groups to Items": {
      "main": [
        [
          {
            "node": "Team Member Weekly Report Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown to HTML": {
      "main": [
        [
          {
            "node": "Send Report to Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch Latest Channel Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Team Member Weekly Report Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Team Weekly Report Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Reports to Single List": {
      "main": [
        [
          {
            "node": "Team Weekly Report Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Messages By UserId": {
      "main": [
        [
          {
            "node": "Groups to Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Team Weekly Report Agent": {
      "main": [
        [
          {
            "node": "Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Report With User Data": {
      "main": [
        [
          {
            "node": "Reports to Single List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Latest Channel Messages": {
      "main": [
        [
          {
            "node": "Group Messages By UserId",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Team Member Weekly Report Agent": {
      "main": [
        [
          {
            "node": "Merge Report With User Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 其他, 人力资源, 人工智能, IT 运维

需要付费吗?

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

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

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

作者
Jimleuk

Jimleuk

@jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

外部链接
在 n8n.io 查看

分享此工作流