OpenClaw 通过 Azure Bot Framework 接入 Microsoft Teams,支持 DM、群组聊天和频道,需要安装插件并创建 Azure Bot 资源。
注意:MS Teams 从 2026.1.15 起移出核心包,需单独安装插件。
安装插件
openclaw plugins install @openclaw/msteams快速接入(5 步)
- 安装 MS Teams 插件
- 创建 Azure Bot(App ID + Client Secret + Tenant ID)
- 配置 OpenClaw 凭证
- 通过公网 URL 或隧道暴露
/api/messages(默认端口 3978) - 安装 Teams 应用包并启动 Gateway
最简配置
{
"channels": {
"msteams": {
"enabled": true,
"appId": "<APP_ID>",
"appPassword": "<APP_PASSWORD>",
"tenantId": "<TENANT_ID>",
"webhook": { "port": 3978, "path": "/api/messages" }
}
}
}群组聊天默认被屏蔽(
groupPolicy: "allowlist")。需设置groupAllowFrom或groupPolicy: "open"开启。
Azure Bot 创建步骤
Step 1:创建 Azure Bot 资源
前往 Azure 门户 - 创建 Azure Bot,填写:
| 字段 | 值 |
|---|---|
| Bot handle | 你的机器人名称(全局唯一) |
| Pricing tier | Free(开发/测试) |
| Type of App | Single Tenant(推荐) |
| Creation type | Create new Microsoft App ID |
注意:2025-07-31 后新建多租户 Bot 已废弃,请使用 Single Tenant。
Step 2:获取凭证
- Azure Bot 资源 → Configuration → 复制 Microsoft App ID(即
appId) - 点击 Manage Password → 进入应用注册
- Certificates & secrets → New client secret → 复制值(即
appPassword) - Overview → 复制 Directory (tenant) ID(即
tenantId)
Step 3:配置 Messaging Endpoint
Azure Bot → Configuration → Messaging endpoint:
https://your-gateway-host:3978/api/messages
Step 4:启用 Teams 频道
Azure Bot → Channels → 添加 Microsoft Teams 频道 → 保存。
本地开发(隧道)
# 使用 ngrok
ngrok http 3978
# 将生成的 HTTPS URL 填入 Azure Bot Messaging Endpoint
# 或使用 Tailscale Funnel
tailscale funnel --bg --set-path /api/messages http://127.0.0.1:3978/api/messages访问控制
DM 访问
{
"channels": {
"msteams": {
"dmPolicy": "pairing",
"allowFrom": ["<AAD_OBJECT_ID>"]
}
}
}重要:使用稳定的 AAD 对象 ID,不要用 UPN(邮箱)或显示名——这些是可变的。
群组和频道访问
{
"channels": {
"msteams": {
"groupPolicy": "allowlist",
"groupAllowFrom": ["user@org.com"],
"teams": {
"My Team": {
"channels": {
"General": { "requireMention": true }
}
}
}
}
}
}RSC 权限(Teams 应用清单)
Teams 应用包需要声明 RSC 权限,示例关键字段:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.17/MicrosoftTeams.schema.json",
"manifestVersion": "1.17",
"id": "<APP_ID>",
"bots": [{
"botId": "<APP_ID>",
"scopes": ["personal", "team", "groupChat"]
}],
"authorization": {
"permissions": {
"resourceSpecific": [
{ "name": "ChannelMessage.Read.Group", "type": "Application" },
{ "name": "ChatMessage.Read.Chat", "type": "Application" },
{ "name": "TeamMember.Read.Group", "type": "Application" }
]
}
}
}RSC vs Graph API 能力对比
| 能力 | RSC Only | RSC + Graph API |
|---|---|---|
| DM 文字消息 | ✅ | ✅ |
| 群聊文字消息 | ✅ | ✅ |
| 频道文字消息 | ✅(已安装) | ✅ |
| 媒体/附件下载 | ❌ | ✅ |
| 频道历史记录 | ❌ | ✅ |
路由与 Session
| 场景 | Session Key |
|---|---|
| DM | agent:<id>:msteams:dm:<userId> |
| 群聊 | agent:<id>:msteams:group:<conversationId> |
| Teams 频道 | agent:<id>:msteams:channel:<channelId> |
附件与图片(DM)
{
"channels": {
"msteams": {
"mediaMaxMb": 20
}
}
}群组/频道发送文件需要 SharePoint 权限,详见官方文档。
故障排查
Bot 无响应:验证 Messaging Endpoint URL;检查 Client Secret 是否过期;确认 Teams 频道已启用。
RSC 权限未生效:重新安装 Teams 应用包;确认清单中 authorization.permissions.resourceSpecific 正确。
清单上传报错:检查必填字段($schema、manifestVersion、id、version、name、icons)。
原文:Microsoft Teams - OpenClaw | 来源:OpenClaw 官方文档