返回顶部
m

microsoft-365-graph-openclaw微软365图形接口

Microsoft 365 Graph for OpenClaw with webhook-based wake signals. Reduce recurring LLM cost from inbox polling while managing Outlook mail, calendar, OneDrive, and contacts via Microsoft Graph.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.2.2
安全检测
已通过
428
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

microsoft-365-graph-openclaw

Microsoft 365 Graph for OpenClaw 技能

1. 快速前提条件

  1. 1. 已安装 requests 库的 Python 3 环境。
  2. 默认认证值:
- 客户端 ID(个人账户默认值):952d1b34-682e-48ce-9c54-bac5a96cbd42 - 租户(个人账户默认值):consumers - 默认作用域:Mail.ReadWrite Mail.Send Calendars.ReadWrite Files.ReadWrite.All Contacts.ReadWrite offline_access - 对于工作/学校账户,请使用 --tenant-id organizations(或租户 GUID)以及租户批准的 --client-id。 - 公共默认客户端 ID 仅用于快速测试。生产环境建议使用您自己的应用注册。
  1. 3. 令牌存储在 state/graph_auth.json 中(已被 git 忽略)。
  2. 推送模式运行时值(服务级别):
- 这些值由 systemd 服务从 /etc/default/graph-mail-webhook 加载(通常由设置脚本写入)。 - OPENCLAWHOOKURL(必需) - OPENCLAWHOOKTOKEN(必需) - GRAPHWEBHOOKCLIENT_STATE(必需;在最小化端到端设置中省略时会自动生成) - OPENCLAWSESSIONKEY(可选;默认为 hook:graph-mail)

权限配置文件(按用例最小权限)记录在 docs/permission-profiles.md 中。

2. 辅助 OAuth 流程(设备代码)

  1. 1. 运行:
bash python scripts/graph_auth.py device-login \ --client-id 952d1b34-682e-48ce-9c54-bac5a96cbd42 \ --tenant-id consumers
  1. 2. 脚本会打印一个 URL设备代码
  2. 打开 https://microsoft.com/devicelogin,输入代码,并使用目标账户批准。
  3. 检查和管理认证状态:
- python scripts/graph_auth.py status - python scripts/graph_auth.py refresh - python scripts/graph_auth.py clear
  1. 5. 其他脚本调用 utils.getaccesstoken(),该函数在需要时自动刷新令牌。
  2. graphauth.py 中禁用了作用域覆盖;该技能始终使用 DEFAULTSCOPES。

详细参考:references/auth.md

3. 邮件操作

  • - 列出/筛选:python scripts/mail_fetch.py --folder Inbox --top 20 --unread
  • 获取特定消息:... --id --include-body --mark-read
  • 移动消息:在上述命令中添加 --move-to
  • 发送邮件(默认启用 saveToSentItems):
bash python scripts/mail_send.py \ --to user@example.com \ --subject 更新 \ --body-file replies/thais.html --html \ --cc teammate@example.com \ --attachment docs/proposal.pdf
  • - 仅在您有意不存储已发送邮件时使用 --no-save-copy。

更多示例和筛选条件:references/mail.md

4. 日历操作

  • - 列出自定义日期范围
bash python scripts/calendar_sync.py list \ --start 2026-03-03T00:00Z --end 2026-03-05T23:59Z --top 50
  • - 创建 Teams 或线下事件:使用 create;添加 --online 以获取 Teams 链接。
  • 对于个人 Microsoft 账户(tenant=consumers),通过 Graph 预配 Teams 会议可能不会返回加入 URL;请先在 Outlook/Teams 中创建 Teams 会议,然后在需要时将生成的链接添加到事件正文中。
  • 更新/取消事件:使用 JSON 输出中返回的 event_id。

完整示例:references/calendar.md

5. OneDrive / 文件

  • - 列出文件夹/文件:python scripts/drive_ops.py list --path /
  • 上传:... upload --local notes/briefing.docx --remote /Clients/briefing.docx
  • 下载:... download --remote /Clients/briefing.docx --local /tmp/briefing.docx
  • 移动/共享链接:使用 move 和 share 子命令。
  • 该脚本可解析本地化/特殊文件夹别名(例如 Documents 和 Documentos)。

更多详情:references/drive.md

6. 联系人

  • - 列出/搜索:python scripts/contacts_ops.py list --top 20
  • 创建:... create --given-name 简 --surname 多伊 --email jane.doe@example.com
  • 更新/删除:... update ... / ... delete
  • 联系人是默认作用域集的一部分,并作为一级工作流得到支持。

更多详情:references/contacts.md

7. 邮件推送模式(Webhook 适配器)

  • - 适配器服务器(Graph 握手 + clientState 验证 + 入队):
bash python scripts/mailwebhookadapter.py serve \ --host 0.0.0.0 --port 8789 --path /graph/mail \ --client-state $GRAPHWEBHOOKCLIENT_STATE
  • - 订阅生命周期(create/status/renew/delete/list):
bash python scripts/mail_subscriptions.py create \ --notification-url https://graph-hook.example.com/graph/mail \ --client-state $GRAPHWEBHOOKCLIENT_STATE \ --minutes 4200

- 默认资源是 me/messages(推荐以获得更好的投递覆盖)。仅在高级/限定范围场景下使用 --resource 覆盖。

  • - 异步工作器(去重 + 默认唤醒信号发送至 OpenClaw /hooks/wake):

bash
python scripts/mailwebhookworker.py loop \
--session-key $OPENCLAWSESSIONKEY \
--hook-url $OPENCLAWHOOKURL \
--hook-token $OPENCLAWHOOKTOKEN

- 默认模式为 wake(/hooks/wake,mode=now)。仅在您明确需要每条消息的丰富负载投递时使用 --hook-action agent。

  • - 工作器队列文件:

- state/mailwebhookqueue.jsonl
- state/mailwebhookdedupe.json
  • - 自动化 EC2 引导(Caddy + systemd + 续订定时器):

bash
sudo bash scripts/setupmailwebhook_ec2.sh \
--domain graphhook.example.com \
--hook-url http://127.0.0.1:18789/hooks/wake \
--hook-token HOOKTOKEN> \
--session-key hook:graph-mail \
--client-state WEBHOOKCLIENT_STATE> \
--repo-root $(pwd)

- 使用 --dry-run 在应用更改前预览所有特权写入和服务操作。

  • - 一键设置(步骤 2..6)

bash
sudo bash scripts/runmailwebhooke2esetup.sh \
--domain graphhook.example.com \
--hook-token HOOKTOKEN> \
--hook-url http://127.0.0.1:18789/hooks/wake \
--session-key hook:graph-mail \
--test-email tar.alitar@outlook.com

- 使用 --dry-run 获取无变更执行计划(不写入 /etc,不执行 systemctl,不创建订阅,不发送邮件)。
- 当设置完全验证通过时,输出以 READYFORPUSH: YES 结束。

  • - 在自动化中包含 OpenClaw 钩子配置

bash
sudo bash scripts/runmailwebhooke2esetup.sh \
--domain graphhook.example.com \
--hook-token HOOKTOKEN> \
--configure-openclaw-hooks \
--openclaw-config /home/ubuntu/.openclaw/openclaw.json \
--openclaw-service-name auto \
--openclaw-hooks-path /hooks \
--openclaw-allow-request-session-key true \
--test-

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 microsoft-365-graph-openclaw-1776198507 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 microsoft-365-graph-openclaw-1776198507 技能

通过命令行安装

skillhub install microsoft-365-graph-openclaw-1776198507

下载

⬇ 下载 microsoft-365-graph-openclaw v0.2.2(免费)

文件大小: 65.12 KB | 发布时间: 2026-4-15 12:10

v0.2.2 最新 2026-4-15 12:10
Version 0.2.2

- Updated documentation to clarify required and optional environment variables for push-mode setup.
- Service-level runtime configuration now emphasizes systemd integration using `/etc/default/graph-mail-webhook`.
- README, SKILL.md, and troubleshooting docs improved for minimal-input and e2e setup workflows.
- Guidance for handling missing or auto-generated `GRAPH_WEBHOOK_CLIENT_STATE` variables in automation scripts.
- No user-facing code changes; this release is documentation-focused.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部