openclaw-custom-bot
v1.0.10
Published
OpenClaw Channel 插件:通过 WebSocket 连接 Custom Bot Server,将 AI Agent 接到自有平台
Readme
openclaw-custom-bot 插件
OpenClaw 的自定义 Bot 通道插件,通过 WebSocket 连接到你的 Custom Bot Server,让 OpenClaw AI Agent 可以接入任意外部平台(企业 IM、机器人框架、自建系统等)。
功能概览
- WebSocket 通道:使用
clientId作为 token 连接中继服务wss://relay.echoclaw.me/ws/gateway - 多 Bot 绑定:一个 OpenClaw 实例可以被多个 Bot 绑定(通过
clientId) - 双向消息收发:支持单聊 / 群聊消息,支持文本 + 媒体 URL
- 无侵入部署:OpenClaw 侧只需安装插件并配置服务端 URL
安装
在有 OpenClaw CLI 的环境中:
openclaw plugins install openclaw-custom-bot开发模式(本仓库内调试):
cd packages/shared && npm install && npm run build
cd ../custom-bot-plugin && npm install && npm run build
openclaw plugins install -l $(pwd)卸载
如果不再需要该通道插件,可以在 OpenClaw 中执行:
openclaw config unset channels.openclaw-custom-bot
openclaw plugins uninstall openclaw-custom-bot配置
在 OpenClaw 配置中设置插件的服务端地址(指向你的 Custom Bot Server):
openclaw config set channels.openclaw-custom-bot.accounts.default.enabled true
openclaw config set plugins.entries.openclaw-custom-bot.config.server_url ws://localhost:3100插件会自动:
- 在本地
~/.openclaw/custom-bot-client-id生成并持久化一个openclaw_clientId - 作为 WebSocket token 连接中继服务
提示:
clientId会在插件启动日志里打印,注册 Bot 时需要用到。
运行机制概览
- 启动时调用
getOrCreateClientId:- 读取或创建
~/.openclaw/custom-bot-client-id
- 读取或创建
- 从 OpenClaw 全局配置中读取
plugins.entries.custom-bot.config.server_url - 使用
WsClient连接到中继服务,并监听来自 Bot Server 的用户消息 - 收到消息后,通过 OpenClaw 的
channel.reply体系转交给 Agent 处理 - Agent 的回复再通过 WebSocket 发回 Bot Server(
type: "agent_reply")
详细的服务端 REST API 与 Webhook 对接方式,见仓库根目录下的 docs/BOT_SERVER_API.md。
