简介
通过本地 Teams 桌面应用自动提取 Token,实现 AI 代理与 Microsoft Teams 的双向交互,支持消息发送、频道读取、表情管理及文件上传。
原始描述
Interact with Microsoft Teams - send messages, read channels, manage reactions
通过你的 Agent 添加
点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。
或者手动安装
包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。
技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。
中文使用说明 来自收录源
核心用法
Agent Teams 是一款 TypeScript CLI 工具,专为 AI 代理与人类协作设计,打通 Microsoft Teams 的自动化操作。核心能力包括:
- 零配置认证:首次使用时自动从本地 Teams 桌面应用提取 Token(存储于
~/.config/agent-messenger/teams-credentials.json),无需手动登录或浏览器操作 - 消息操作:发送、读取、删除消息,支持频道历史回溯与消息检索
- 频道与团队管理:列出现有频道/团队、切换活跃团队、获取成员列表
- 反应与文件:添加/移除消息表情反应,上传文件至频道
- 快照模式:一键导出完整团队状态(频道、成员、近期消息)为 JSON,便于 AI 代理快速建立上下文
- 多账户支持:Work/Personal 账户切换,支持单命令指定账户
Memory 机制:通过 ~/.config/agent-messenger/MEMORY.md 持久化存储 Team ID、Channel ID、用户别名等,避免重复查询。
显著优点
- 自动化 Token 管理:60-90 分钟 Token 过期后自动刷新,无需人工干预
- AI 原生设计:默认 JSON 输出,支持
--pretty人类可读模式,适配自动化工作流 - 本地安全存储:凭证文件权限 0600,Token 不暴露在环境变量或代码中
- 轻量无侵入:仅读取 Teams 桌面应用本地 SQLite/Cookies,不修改应用行为
潜在缺点与局限性
- 无实时事件:缺乏 WebSocket,无法主动推送消息(需轮询)
- 功能边界:不支持语音/视频频道、会议管理、Webhook、自适应卡片(Adaptive Cards)
- Token 依赖:必须保持 Teams 桌面应用登录状态,若应用退出或会话过期需重新登录
- 平台限制:仅支持 Windows/macOS(依赖本地 Teams 应用),无 Linux 原生方案
- 纯文本消息:v1 版本不支持富媒体消息格式
适合人群
- 需将 Teams 集成至自动化工作流的开发者/DevOps 工程师
- 使用 AI 代理(如 Claude、GPT)辅助团队协作的高级用户
- 需批量操作 Teams 消息/文件的系统管理员
- 希望减少重复性 Teams 操作(如定时发送报告)的办公自动化用户
常规风险
| 风险类型 | 说明 | 缓解措施 |
|---|---|---|
| Token 泄露 | 本地凭证文件若被恶意程序读取,可 impersonate 用户发送消息 | 确保 ~/.config/agent-messenger/ 目录权限严格,定期审计文件访问日志 |
| 会话过期 | Teams 桌面应用登出后 Token 失效,导致自动化任务中断 | 监控 auth status,设置失败重试与人工告警机制 |
| 误操作广播 | AI 代理可能误发消息至错误频道(尤其多团队场景) | 强制使用 Channel ID(非名称),关键操作前要求人工确认 |
| Rate Limiting | 高频调用可能触发 Microsoft Graph API 限制 | 合理设置轮询间隔,使用 snapshot 减少重复查询 |
| Memory 污染 | MEMORY.md 中的过期 ID 可能导致操作失败或信息泄露 |
定期验证 ID 有效性,错误时自动清理 |
架构安全评估
该工具采用本地凭证提取 + 用户 Token 调用 Graph API 的架构,不涉及 OAuth App 或第三方服务中转,数据流完全本地闭环。相比传统「浏览器模拟登录」方案,减少了中间人攻击面,但仍依赖 Teams 桌面应用的安全状态。
技能正文
name: agent-teams description: Interact with Microsoft Teams - send messages, read channels, manage reactions version: 1.10.5 allowed-tools: Bash(agent-teams:*) metadata: openclaw: requires: bins: - agent-teams install: - kind: node package: agent-messenger bins: [agent-teams]
Agent Teams
A TypeScript CLI tool that enables AI agents and humans to interact with Microsoft Teams through a simple command interface. Features seamless token extraction from the Teams desktop app and multi-team support.
Quick Start
# Get team snapshot (credentials are extracted automatically)
agent-teams snapshot
# Send a message
agent-teams message send <team-id> <channel-id> "Hello from AI agent!"
# List channels
agent-teams channel list <team-id>
Authentication
Credentials are extracted automatically from the Teams desktop app on first use. No manual setup required — just run any command and authentication happens silently in the background.
Teams tokens expire in 60-90 minutes. The CLI automatically re-extracts a fresh token when the current one expires, so you don't need to manage token lifecycle manually.
IMPORTANT: NEVER guide the user to open a web browser, use DevTools, or manually copy tokens from a browser. Always use agent-teams auth extract to obtain tokens from the desktop app.
Multi-Team Support
# List all available teams
agent-teams team list
# Switch to a different team
agent-teams team switch <team-id>
# Show current team
agent-teams team current
# Check auth status (includes token expiry info)
agent-teams auth status
Multi-Account Support (Work / Personal)
# Switch between work and personal accounts
agent-teams auth switch-account work
agent-teams auth switch-account personal
# Use a specific account for one command (without switching)
agent-teams snapshot --account work
Memory
The agent maintains a ~/.config/agent-messenger/MEMORY.md file as persistent memory across sessions. This is agent-managed — the CLI does not read or write this file. Use the Read and Write tools to manage your memory file.
Reading Memory
At the start of every task, read ~/.config/agent-messenger/MEMORY.md using the Read tool to load any previously discovered team IDs, channel IDs, user IDs, and preferences.
- If the file doesn't exist yet, that's fine — proceed without it and create it when you first have useful information to store.
- If the file can't be read (permissions, missing directory), proceed without memory — don't error out.
Writing Memory
After discovering useful information, update ~/.config/agent-messenger/MEMORY.md using the Write tool. Write triggers include:
- After discovering team IDs and names (from
team list,snapshot, etc.) - After discovering useful channel IDs and names (from
channel list,snapshot, etc.) - After discovering user IDs and names (from
user list,user me, etc.) - After the user gives you an alias or preference ("call this the standup channel", "my main team is X")
- After discovering channel structure (standard vs private channels)
When writing, include the complete file content — the Write tool overwrites the entire file.
What to Store
- Team IDs with names
- Channel IDs with names and team context
- User IDs with display names
- User-given aliases ("standup channel", "main team")
- Account preferences (work vs personal)
- Any user preference expressed during interaction
What NOT to Store
Never store tokens, credentials, or any sensitive data. Never store full message content (just IDs and channel context). Never store file upload contents.
Handling Stale Data
If a memorized ID returns an error (channel not found, team not found), remove it from MEMORY.md. Don't blindly trust memorized data — verify when something seems off. Prefer re-listing over using a memorized ID that might be stale.
Format / Example
# Agent Messenger Memory
## Teams
- `team-id-1` — Acme Corp (default, work account)
- `team-id-2` — Side Project (personal account)
## Channels (Acme Corp)
- `channel-id-1` — General
- `channel-id-2` — Engineering
- `channel-id-3` — Standups
## Users (Acme Corp)
- `user-id-1` — Alice (engineering lead)
- `user-id-2` — Bob (backend)
## Aliases
- "standup" → `channel-id-3` (Standups in Acme Corp)
- "main team" → `team-id-1` (Acme Corp)
## Notes
- User prefers work account by default
- Main team is "Acme Corp"
Memory lets you skip repeated
channel listandteam listcalls. When you already know an ID from a previous session, use it directly.
Commands
Auth Commands
# Extract token from Teams desktop app (usually automatic)
agent-teams auth extract
agent-teams auth extract --debug
# Check auth status (includes token expiry info)
agent-teams auth status
# Logout from Microsoft Teams
agent-teams auth logout
# Switch between work and personal accounts
agent-teams auth switch-account <account-type>
agent-teams auth switch-account work
agent-teams auth switch-account personal
Message Commands
# Send a message
agent-teams message send <team-id> <channel-id> <content>
agent-teams message send <team-id> 19:abc123@thread.tacv2 "Hello world"
# List messages
agent-teams message list <team-id> <channel-id>
agent-teams message list <team-id> 19:abc123@thread.tacv2 --limit 50
# Get a single message by ID
agent-teams message get <team-id> <channel-id> <message-id>
# Delete a message
agent-teams message delete <team-id> <channel-id> <message-id> --force
Channel Commands
# List channels in a team
agent-teams channel list <team-id>
# Get channel info
agent-teams channel info <team-id> <channel-id>
agent-teams channel info <team-id> 19:abc123@thread.tacv2
# Get channel history (alias for message list)
agent-teams channel history <team-id> <channel-id> --limit 100
Team Commands
# List all teams
agent-teams team list
# Get team info
agent-teams team info <team-id>
# Switch active team
agent-teams team switch <team-id>
# Show current team
agent-teams team current
# Remove a team from config
agent-teams team remove <team-id>
User Commands
# List team members
agent-teams user list <team-id>
# Get user info
agent-teams user info <user-id>
# Get current user
agent-teams user me
Reaction Commands
# Add reaction (use emoji name)
agent-teams reaction add <team-id> <channel-id> <message-id> <emoji>
agent-teams reaction add <team-id> 19:abc123@thread.tacv2 1234567890 like
# Remove reaction
agent-teams reaction remove <team-id> <channel-id> <message-id> <emoji>
File Commands
# Upload file
agent-teams file upload <team-id> <channel-id> <path>
agent-teams file upload <team-id> 19:abc123@thread.tacv2 ./report.pdf
# List files in channel
agent-teams file list <team-id> <channel-id>
# Get file info
agent-teams file info <team-id> <channel-id> <file-id>
Snapshot Command
Get comprehensive team state for AI agents:
# Full snapshot
agent-teams snapshot
# Filtered snapshots
agent-teams snapshot --channels-only
agent-teams snapshot --users-only
# Limit messages per channel
agent-teams snapshot --limit 10
Returns JSON with:
- Team metadata (id, name)
- Channels (id, name, type, description)
- Recent messages (id, content, author, timestamp)
- Members (id, displayName, email)
Output Format
JSON (Default)
All commands output JSON by default for AI consumption:
{
"id": "19:abc123@thread.tacv2",
"content": "Hello world",
"author": "John Doe",
"timestamp": "2024-01-15T10:30:00.000Z"
}
Pretty (Human-Readable)
Use --pretty flag for formatted output:
agent-teams channel list --pretty
Key Differences from Discord/Slack
| Feature | Teams | Discord | Slack |
|---|---|---|---|
| Server terminology | Team | Guild | Workspace |
| Channel identifiers | UUID format (19:xxx@thread.tacv2) | Snowflake IDs | Channel name or ID |
| Token storage | Cookies SQLite | LevelDB | LevelDB |
| Token expiry | 60-90 minutes | Rarely expires | Rarely expires |
| Mentions | <at id="user-id">Name</at> |
<@user_id> |
<@USER_ID> |
Important: Teams uses UUID-style channel IDs (like 19:abc123@thread.tacv2). You cannot use channel names directly - use channel list to find IDs first.
Common Patterns
See references/common-patterns.md for typical AI agent workflows.
Templates
See templates/ directory for runnable examples:
post-message.sh- Send messages with error handlingmonitor-channel.sh- Monitor channel for new messages (with token refresh)team-summary.sh- Generate team summary
Error Handling
All commands return consistent error format:
{
"error": "Not authenticated. Run \"auth extract\" first."
}
Common errors:
Not authenticated: No valid token (auto-extraction failed — see Troubleshooting)Token expired: Token has expired and auto-refresh failed — see TroubleshootingNo current team set: Runteam switch <id>firstMessage not found: Invalid message IDChannel not found: Invalid channel ID401 Unauthorized: Token expired and auto-refresh failed — see Troubleshooting
Configuration
Credentials stored in: ~/.config/agent-messenger/teams-credentials.json
Format:
{
"token": "skypetoken_asm_value_here",
"token_extracted_at": "2024-01-15T10:00:00.000Z",
"current_team": "team-uuid-here",
"teams": {
"team-uuid-here": {
"team_id": "team-uuid-here",
"team_name": "My Team"
}
}
}
Security: File permissions set to 0600 (owner read/write only)
Limitations
- No real-time events / WebSocket connection
- No voice/video channel support
- No team management (create/delete channels, roles)
- No meeting support
- No webhook support
- Plain text messages only (no adaptive cards in v1)
- User tokens only (no app tokens)
- Token expires in 60-90 minutes - auto-refreshed, but requires Teams desktop app to be logged in
Troubleshooting
Authentication fails or token expired
Credentials and token refresh are normally handled automatically. If auto-extraction fails, run it manually with debug output:
agent-teams auth extract --debug
Common causes:
- Teams desktop app is not installed or not logged in
- Teams Cookies database is locked or inaccessible
- Token expired and Teams desktop app session also expired (re-login to Teams)
agent-teams: command not found
agent-teams is NOT the npm package name. The npm package is agent-messenger.
If the package is installed globally, use agent-teams directly:
agent-teams team list
If the package is NOT installed, use bunx agent-messenger teams:
bunx agent-messenger teams team list
NEVER run bunx agent-teams — it will fail or install a wrong package since agent-teams is not the npm package name.
References
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。