@workclawdev/extension-bot-chat
v0.1.0
Published
OpenClaw extension for BotChat bridge (MQTT + permission approval)
Downloads
128
Readme
OpenClaw BotChat Extension
OpenClaw channel extension for bridging OpenClaw to BotChat through the BotChat backend and MQTT broker.
Install
npm install @workclawdev/extension-bot-chatThis publishes under the WorkClawDev namespace. The npm scope is written as lowercase @workclawdev because npm package names must be lowercase.
The package prints a non-secret QR code during install when lifecycle script output is shown by npm. The same QR can be shown again at any time:
npx @workclawdev/extension-bot-chatSet OPENCLAW_BOTCHAT_SKIP_POSTINSTALL_QR=1 to suppress install-time QR output.
iOS Binding QR
The install/setup QR never includes BOT_CHAT_BOT_KEY or other secrets.
By default it encodes:
openclaw://extensions/install?package=@workclawdev%2Fextension-bot-chat&channel=bot-chatFor a deployment-specific iOS binding URL, provide one of these before running install or setup:
OPENCLAW_BOTCHAT_BIND_URL="https://clawchat.example.com/openclaw/bind?token=..." npx @workclawdev/extension-bot-chator:
BOT_CHAT_BACKEND_URL="https://clawchat.example.com" \
BOT_CHAT_BIND_TOKEN="ocbb_replace_with_one_time_binding_token" \
npx @workclawdev/extension-bot-chatThe token form is preferred. Create it from the BotChat API:
POST /api/v1/bots/<bot UUID>/bindingsThe response includes a short-lived bind_url and token. iOS consumes the token with:
POST /api/v1/bot-bindings/confirmLegacy bot id QR codes are still recognized for compatibility:
BOT_CHAT_BACKEND_URL="https://clawchat.example.com" \
BOT_CHAT_BOT_ID="replace_with_bot_uuid" \
npx @workclawdev/extension-bot-chatThe second form generates:
https://clawchat.example.com/openclaw/bind?package=@workclawdev/extension-bot-chat&channel=bot-chat&botId=<bot UUID>Configuration
Minimal OpenClaw channel config:
{
"channels": {
"bot-chat": {
"backendUrl": "http://127.0.0.1:8080",
"botKey": "ocbk_replace_with_one_time_bot_key",
"botId": "replace_with_bot_uuid"
}
}
}Recommended config for local development:
{
"channels": {
"bot-chat": {
"backendUrl": "http://127.0.0.1:8080",
"botKey": "ocbk_replace_with_one_time_bot_key",
"botId": "replace_with_bot_uuid",
"mqttTcpUrl": "mqtt://127.0.0.1:1883",
"defaultTo": "group:replace_with_group_uuid",
"allowFrom": ["*"],
"stateDir": "./data",
"historyCatchupLimit": 100
}
}
}botKey can also be an OpenClaw secret reference:
{
"source": "env",
"provider": "default",
"id": "BOT_CHAT_BOT_KEY"
}BotChat Runtime Contract
The extension uses the BotChat bot-runtime contract:
GET /api/v1/bot-runtime/bootstrapwithX-Bot-KeyGET /api/v1/bot-runtime/messages/<conversation_id>?limit=<n>&after_seq=<seq>withX-Bot-KeyGET /api/v1/bot-runtime/tasks/queuewithX-Bot-Key; older backends can still be read throughGET /api/v1/bot-runtime/tasksPOST /api/v1/bot-runtime/taskswithX-Bot-KeyPOST /api/v1/bot-runtime/tasks/<task_id>/{claim|progress|result|fail}withX-Bot-Key;resultfalls back to legacycompletewhen unavailable- MQTT publish topics that BotChat can persist:
- DM:
chat/dm/user/<userId>/bot/<botId> - Group:
chat/group/<groupId>
- DM:
Task assignment does not execute a task by itself. A running bot process must consume the task runtime API and post progress, result, or failure. The extension polls runnable tasks from /tasks/queue when the OpenClaw host supplies channelRuntime.runTask or channelRuntime.tasks.runTask; without that hook it leaves task state unchanged instead of claiming work it cannot execute. For compatibility it falls back to the older task list endpoint when /tasks/queue is unavailable.
runTask(task, context) receives a task plus helpers:
context.progress(progress, note)orcontext.progress(note, progress)posts progress updates.context.createTask(payload)postsPOST /api/v1/bot-runtime/tasks, so a runtime can create child tasks. The helper automatically adds the current task asparent_task_idunless the payload overrides it.
When runTask returns an object, the extension posts it as result to /bot-runtime/tasks/<task_id>/result together with latest_status_note. Fields such as summary, output, artifacts, and metadata are preserved. Thrown errors are reported to /fail with both latest_status_note and a structured error object.
Target Mapping
| OpenClaw target | BotChat publish topic |
| --- | --- |
| dm:<userId> / user:<userId> | chat/dm/user/<userId>/bot/<botId> |
| group:<groupId> | chat/group/<groupId> |
| channel:<conversationId> | <conversationId> |
| raw target | channel:<raw> |
Development
npm run check
npm test
npm run build
npm pack --dry-run