Teams Delegate
Let the agent own your Teams inbox. Read messages, draft replies, send them — with awareness of who's messaging you and what actually needs your attention.
Setup (one time)
- 1. Register an Azure app at https://portal.azure.com → Azure Active Directory → App Registrations → New
- Platform: Mobile/Desktop (enables device code flow)
- In Authentication → scroll to "Advanced settings" → set "Allow public client flows" to Yes (required for device code)
- NOTE: Use the old Azure portal experience — click "switch to old experience" in the yellow banner if you see it
- Add API permissions: Chat.Read, Chat.ReadWrite, ChannelMessage.Read.All, ChannelMessage.Send, Presence.Read.All, User.Read
- Grant admin consent if on a corporate tenant
- 2. Save the client ID:
CODEBLOCK0
- 3. Authenticate:
python3 scripts/auth.py
Follow the device code prompt. Token saved to ~/.teams-delegate/token.json and auto-refreshes.
Core Commands
CODEBLOCK2
Agent Workflow
Checking the inbox
- 1. Run
summary to get all recent conversations in one pass - Classify each message:
-
Agent handles: acknowledgements, scheduling confirmations, "got it" responses, simple status updates
-
Needs human: decisions, sensitive topics, anything the user explicitly wants to see, urgent/high importance from boss
- 3. For messages the agent handles: draft reply → run INLINECODE1
- For messages needing human: summarize and present to user
Drafting replies
- - Match the tone of the conversation (casual 1:1 vs formal channel)
- Keep it brief — Teams is chat, not email
- If replying on behalf of someone, don't pretend to be them; write as their assistant if context requires
- Check
importance field — urgent messages from managers need immediate escalation to user
Auto-reply mode
When user says "handle my Teams" or "auto-reply while I'm out":
- 1. Run
summary every N minutes (use cron or heartbeat) - Apply classification rules above
- Send approved replies automatically
- Log everything — what was sent, to whom, when
- Alert user for anything flagged as needing human attention
Priority Rules (defaults — user can override)
- - Messages marked
urgent → always escalate to user - Messages from designated VIPs (boss, key clients) → draft only, wait for approval
- Group chat messages → lower priority, reply only if directly @mentioned
- Channel messages → summarize only unless @mentioned
Graph API Reference
See references/graph-api.md for full endpoint docs, auth scopes, and rate limit details.
Author
Built by Nate Teshome — @takeovernat
Website: stellarsitesai.com
GitHub: github.com/takeovernat
Found a bug or want to contribute? Open an issue or PR on GitHub.
Teams Delegate
让代理掌控你的Teams收件箱。读取消息、起草回复、发送消息——同时清楚谁在联系你以及哪些内容真正需要你关注。
设置(一次性操作)
- 1. 在 https://portal.azure.com 注册Azure应用 → Azure Active Directory → 应用注册 → 新建
- 平台:移动/桌面(启用设备代码流程)
- 在身份验证中 → 滚动到高级设置 → 将允许公共客户端流设置为是(设备代码必需)
- 注意:使用旧版Azure门户体验——如果看到黄色横幅,点击切换到旧版体验
- 添加API权限:Chat.Read、Chat.ReadWrite、ChannelMessage.Read.All、ChannelMessage.Send、Presence.Read.All、User.Read
- 如果使用企业租户,需授予管理员同意
- 2. 保存客户端ID:
python3 scripts/auth.py --client-id 你的客户端ID
- 3. 身份验证:
python3 scripts/auth.py
按照设备代码提示操作。令牌保存至 ~/.teams-delegate/token.json 并自动刷新。
核心命令
bash
python3 scripts/teams.py inbox # 列出最近的聊天及预览
python3 scripts/teams.py read # 阅读完整对话
python3 scripts/teams.py reply 消息内容 # 发送回复
python3 scripts/teams.py summary # 转储所有待处理聊天供代理审查
代理工作流程
检查收件箱
- 1. 运行 summary 一次性获取所有最近对话
- 对每条消息进行分类:
-
代理处理: 确认、日程确认、收到回复、简单状态更新
-
需人工处理: 决策、敏感话题、用户明确要求查看的内容、来自上级的紧急/高重要性消息
- 3. 对于代理处理的消息:起草回复 → 运行 reply
- 对于需人工处理的消息:总结并呈现给用户
起草回复
- - 匹配对话语气(随意的1对1对话 vs 正式频道)
- 保持简洁——Teams是聊天工具,不是邮件
- 如果代表他人回复,不要假装成对方;根据上下文以助手身份撰写
- 检查 importance 字段——来自管理员的紧急消息需立即上报给用户
自动回复模式
当用户说帮我处理Teams或我不在时自动回复时:
- 1. 每N分钟运行一次 summary(使用cron或心跳检测)
- 应用上述分类规则
- 自动发送已批准的回复
- 记录所有操作——发送内容、发送对象、发送时间
- 对标记为需人工关注的内容提醒用户
优先级规则(默认设置——用户可覆盖)
- - 标记为 urgent 的消息 → 始终上报给用户
- 来自指定VIP(老板、关键客户)的消息 → 仅起草,等待批准
- 群聊消息 → 较低优先级,仅在直接@提及时才回复
- 频道消息 → 仅总结,除非被@提及
Graph API参考
完整端点文档、认证范围和速率限制详情请参见 references/graph-api.md。
作者
由 Nate Teshome 构建 — @takeovernat
网站:stellarsitesai.com
GitHub:github.com/takeovernat
发现Bug或想贡献代码?请在GitHub上提交Issue或PR。