--- name: wechat-chatbot description: 通过本仓库 web2 的 /chatbot/wechat API 配置微信代理 Chatbot、扫码登录与发消息(与 openclaw-wechat 代理协议一致)。 --- # 微信 Chatbot(HTTP API) 后端基址默认 `http://127.0.0.1:8001`(或 `WEB2_API_BASE`)。若启用 `WEB2_API_TOKEN`,请求需带 `Authorization: Bearer `。 ## 配置 - 复制 `config/wechat_chatbot.example.json` 为 `config/wechat_chatbot.json`,填写 `apiKey`、`proxyUrl`(由代理服务商提供,与 [openclaw-wechat](https://github.com/freestylefly/openclaw-wechat) 一致)。 - 或通过 API 写入:`POST /chatbot/wechat/config`,JSON 字段见示例文件。 ## 常用端点 | 方法 | 路径 | 说明 | |------|------|------| | GET | `/chatbot/wechat/config` | 查看配置(apiKey 脱敏)与本地会话摘要 | | POST | `/chatbot/wechat/config` | 保存配置 | | GET | `/chatbot/wechat/proxy/status` | 代理账号状态 | | POST | `/chatbot/wechat/qr/start` | 获取登录二维码 URL 与 `wId` | | POST | `/chatbot/wechat/login/check` | Body:`{"wId":"..."}`,轮询直至 `logged_in` | | POST | `/chatbot/wechat/send` | Body:`{"targetId":"wxid或群id","text":"..."}` | | POST | `/chatbot/wechat/webhook/register` | Body:`{"webhookUrl":"https://..."}` 供云端收消息 | ## CLI ```bash python wechat_chatbot_cli.py config-get --json python wechat_chatbot_cli.py qr-start --json python wechat_chatbot_cli.py login-check --w-id --json python wechat_chatbot_cli.py send --target --text "hi" --json ``` ## 与 CLI-Anything / Agent 的协作方式 - 优先使用 **`--json`** 或解析 HTTP JSON,便于与 [CLI-Anything](https://github.com/HKUDS/CLI-Anything) 类工具链衔接。 - 扫码流程:先 `qr/start` 展示 `qrCodeUrl`,每约 5 秒调用 `login/check` 直至成功或超时。