Microsoft Teams 通道
通过 Microsoft Teams 与 Moltbot 进行交互。
先决条件
- Azure AD 应用注册
- Microsoft Graph API 权限
- Teams 许可
配置
创建 Azure AD 应用
- 访问 Azure Portal
- Azure Active Directory → 应用注册 → 新注册
- 设置重定向 URI:
https://localhost:18789/callback/msteams - 创建客户端密钥
配置 API 权限
在 API 权限中添加:
ChannelMessage.Send(团队消息发送)Chat.ReadWrite(聊天读写)User.Read(用户读取)offline_access(刷新令牌)
添加通道
bash
moltbot channels add --channel msteams \
--account default \
--tenant-id your-tenant-id \
--client-id your-client-id \
--client-secret your-client-secret使用
发送消息
bash
# 发送到团队频道
moltbot message send --channel msteams --target "team:team-id:channel:channel-id" --message "Hello Teams!"
# 发送至聊天
moltbot message send --channel msteams --target "chat:chat-id" --message "Hello chat!"发送 Adaptive Card
bash
moltbot message send --channel msteams \
--target "team:team-id:channel:channel-id" \
--card @/path/to/card.json功能
支持的消息类型
- ✅ 文本消息
- ✅ 代码块
- ✅ 附件
- ✅ Adaptive Cards
- ✅ 提及用户
- ✅ 线程回复
- ✅ 表情反应
- ❌ 语音消息
- ❌ 视频通话
故障排除
身份验证问题
bash
# 重新进行身份验证
moltbot channels login --channel msteams --account default权限不足
检查 Azure AD 应用的 API 权限配置,确保已授予所有必要权限并获得管理员同意。