Co-Pilot / 辅助式
更新于 24 days ago

microsoft-teams-send-as-workflow

Nnocoo
0.0k
nocoo/microsoft-teams-send-as-workflow
78
Agent 评分

💡 摘要

此技能通过传入Webhook将消息和自适应卡发送到Microsoft Teams。

🎯 适合人群

DevOps工程师项目经理软件开发人员IT支持团队业务分析师

🤖 AI 吐槽:该工具需要网络访问以发送消息,如果Webhook URL被泄露,可能会暴露敏感数据。缓解措施包括使用环境变量安全存储敏感信息。

安全分析中风险

风险:Medium。建议检查:是否执行 shell/命令行指令;是否发起外网请求(SSRF/数据外发)。以最小权限运行,并在生产环境启用前审计代码与依赖。


name: microsoft-teams-send-as-workflow description: Send messages and Adaptive Cards to Microsoft Teams via Incoming Webhook. Use when user requests to send notifications, alerts, or formatted cards to Teams channels. Triggers include requests to post to Teams, Teams webhook, Teams notification, Teams card, or any request to send messages to Microsoft Teams channels.

Microsoft Teams Post

Send messages and Adaptive Cards to Microsoft Teams channels using Incoming Webhook URLs.

Prerequisites

Users need a Webhook URL from Teams. Guide them to create one if missing:

  1. In Teams, go to the target channel
  2. Open Workflows app (search from Apps or click three dots below input)
  3. Find template: "Post to a channel when a webhook request is received"
  4. Name the workflow (e.g., "CLI Notification Bot")
  5. Select target Team and Channel
  6. Copy the generated HTTP POST URL

Quick Start

The bundled script scripts/send_teams.py handles all message types.

python3 scripts/send_teams.py <WEBHOOK_URL> --text "Hello Teams!"

Message Types

Simple Text Message

For basic notifications and alerts.

python3 scripts/send_teams.py <WEBHOOK_URL> -t "🚀 Deployment completed successfully"

Adaptive Card

For rich formatted cards with titles, facts, images, and buttons. Pass JSON as string or file.

Inline JSON:

python3 scripts/send_teams.py <WEBHOOK_URL> -c '{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.4", "body": [ { "type": "TextBlock", "text": "Build Report", "weight": "Bolder", "size": "Medium" }, { "type": "FactSet", "facts": [ {"title": "Project", "value": "Backend API"}, {"title": "Status", "value": "✅ Success"}, {"title": "Duration", "value": "45s"} ] } ] }'

From JSON file:

python3 scripts/send_teams.py <WEBHOOK_URL> -c card.json

Raw Payload

For custom message structures not covered by text or card modes.

python3 scripts/send_teams.py <WEBHOOK_URL> -r '{"type": "message", "text": "Custom"}'

Common Patterns

Build/Deployment Notification

python3 scripts/send_teams.py <WEBHOOK_URL> -c '{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.4", "body": [ {"type": "TextBlock", "text": "Deployment Notification", "weight": "Bolder", "size": "Medium"}, {"type": "TextBlock", "text": "Project: my-app deployed to production", "wrap": true} ], "actions": [ {"type": "Action.OpenUrl", "title": "View Logs", "url": "https://ci.example.com/logs/123"} ] }'

Alert with Facts

python3 scripts/send_teams.py <WEBHOOK_URL> -c '{ "type": "AdaptiveCard", "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.4", "body": [ {"type": "TextBlock", "text": "⚠️ Alert Summary", "weight": "Bolder"}, { "type": "FactSet", "facts": [ {"title": "Severity", "value": "High"}, {"title": "Service", "value": "api-gateway"}, {"title": "Time", "value": "2026-01-23 09:45:00 UTC"} ] } ] }'

Script Reference

scripts/send_teams.py

| Argument | Description | |----------|-------------| | webhook_url | Teams Incoming Webhook URL (required positional) | | -t, --text TEXT | Send simple text message | | -c, --card CARD | Send Adaptive Card (JSON string or .json file) | | -r, --raw RAW | Send raw custom payload (JSON string or .json file) | | -v, --verbose | Enable verbose output |

Exit codes: 0 on success, 1 on failure.

Error Handling

The script reports errors clearly:

  • ❌ HTTP Error: 401 - Invalid webhook URL
  • ❌ HTTP Error: 400 - Malformed JSON or invalid card schema
  • ❌ URL Error - Network connectivity issue
  • ✅ Message sent successfully - Confirmed delivery

For 4xx errors, the response body is printed to help diagnose schema issues.

Suspended Workflow

If you receive errors indicating the workflow is "suspended" or "inactive":

  1. Open Power Automate in your browser:

    • https://make.powerautomate.com
    • OR your org's URL: https://.powerautomate.com
  2. Go to My flows / Workflows

  3. Find your workflow (look for "Suspended" status)

  4. Click → Resume / Activate / Turn on

  5. Retry sending your message

五维分析
清晰度8/10
创新性7/10
实用性9/10
完整性8/10
可维护性7/10
优缺点分析

优点

  • 支持多种消息格式。
  • 与Microsoft Teams的轻松集成。
  • 清晰的错误处理和报告。

缺点

  • 需要设置传入Webhook。
  • 仅限于Teams消息功能。
  • 依赖外部网络连接。

相关技能

claude-mods

A
toolCo-Pilot / 辅助式
86/ 100

“看起来很能打,但别让配置把人劝退。”

mcpspy

A
toolCo-Pilot / 辅助式
86/ 100

“MCPSpy:因为谁不想窥探他们 AI 的秘密?”

candid

A
toolCo-Pilot / 辅助式
86/ 100

“看起来很能打,但别让配置把人劝退。”

免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。

版权归原作者所有 nocoo.