Files
picoclaw/docs/channels/wecom/wecom_aibot
ZHANG RUI 9a25fad20a Implement the latest long-connection mode for the WeCom AI Bot. (#1295)
* feat(wecom): add WebSocket long-connection support for WeCom AI Bot

- Introduced WeComAIBotWSChannel to handle WebSocket connections.
- Updated NewWeComAIBotChannel to prioritize WebSocket mode when BotID and Secret are provided.
- Enhanced WeComAIBotConfig to include BotID and Secret for WebSocket mode.
- Implemented message handling for text, image, voice, and mixed messages in WebSocket mode.
- Added tests for WebSocket mode functionality and ensured backward compatibility with webhook mode.
- Refactored existing code to improve clarity and maintainability.

* feat(wecom): implement periodic processing hints and enforce WeCom stream deadline

* feat(wecom): update WeCom AI Bot setup instructions and configuration parameters

* feat(wecom): enhance WeCom AI Bot with image handling and media support

* feat(wecom): refactor WeCom AI Bot task management to use req_id for concurrent message handling

* feat(wecom): refactor WeCom AI Bot to manage request states and late replies

* feat(wecom): add response timeout handling and improve WebSocket command acknowledgment

* fix(wecom): improve error handling for late reply proactive push delivery

* refactor(wecom): reorganize WeCom AI Bot configuration fields for improved readability

* fix(wecom): update error message for websocket delivery failure in late reply proactive push

* feat(wecom): implement shared HTTP clients for WeCom image handling and response URL posting

* refactor(wecom): simplify image download and storage process in storeWSImage

* fix(wecom): improve error logging for WebSocket message handling and proactive push delivery

* fix(wecom): enhance WebSocket connection stability and task cancellation handling

* fix(wecom): improve WS image message handling by ensuring proper error response and initializing mediaRefs

* feat(wecom): enhance WeCom AIBot WebSocket handling with message deduplication and support for file and video messages

* refactor(wecom): rename image handling functions to media handling and enhance media type support

* feat(wecom): implement byte-aware content splitting for WeCom AI Bot stream messages

* refactor(wecom): remove max message length constraint from WeCom AIBot WS channel
2026-03-19 20:06:51 +08:00
..

企业微信智能机器人 (AI Bot)

企业微信智能机器人(AI Bot)是企业微信官方提供的 AI 对话接入方式,支持私聊与群聊,内置流式响应协议。

与其他 WeCom 通道的对比

特性 WeCom Bot WeCom App WeCom AI Bot
私聊
群聊
流式输出
超时主动推送
配置复杂度

配置

{
  "channels": {
    "wecom_aibot": {
      "enabled": true,
      "bot_id": "YOUR_BOT_ID",
      "secret": "YOUR_SECRET",
      "allow_from": [],
      "welcome_message": "你好!有什么可以帮助你的吗?",
      "max_steps": 10
    }
  }
}
字段 类型 必填 描述
bot_id string AI Bot 的唯一标识,在 AI Bot 管理页面配置
secret string AI Bot 的密钥,在 AI Bot 管理页面配置
allow_from array 用户 ID 白名单,空数组表示允许所有用户
welcome_message string 用户进入聊天时发送的欢迎语,留空则不发送
reply_timeout int 回复超时时间(秒,默认:5
max_steps int Agent 最大执行步骤数(默认:10)

设置流程

  1. 登录 企业微信管理后台
  2. 进入"应用管理" → "智能机器人",创建或选择一个 AI Bot
  3. 在 AI Bot 配置页面,配置Bot的名称、头像等信息,获取 Bot IDSecret
  4. 在 PicoClaw 配置文件中添加上述配置,重启 PicoClaw

欢迎语

配置 welcome_message 后,当用户打开与 AI Bot 的聊天窗口时(enter_chat 事件),PicoClaw 会自动回复该欢迎语。留空则静默忽略。

"welcome_message": "你好!我是 PicoClaw AI 助手,有什么可以帮你?"

常见问题

消息没有回复

  • 检查 allow_from 是否意外限制了发送者
  • 查看日志中是否出现 context canceled 或 Agent 错误
  • 确认 Agent 配置(model_name 等)正确

参考文档