API pipeline: Run a self-hosted Cabi.Chat widget with your own program

Index: API pipelines — index

Goal: your own program answers people in a Cabi.Chat widget's rooms: a script, a support service, or your own AI assistant such as Claude Code. Cabi.Chat gives the widget a token that works like a Telegram bot token; Cabi.Chat's AI does not answer. What a widget is and who can reach it: Cabi.Chat Oracles — Cabi.Chat widget

Steps

1. Create.

POST /v0/my/oracles
Idempotency-Key: widget-mine-1
{"kind": "cabi_widget", "hosting": "self", "title": "My assistant", "project": "<project nonce>"}
→ {"nonce": "470000000000000004", "card_type": "oracle", "kind": "cabi_widget",
   "status": "STOPPED", "token": "…", …}

2. Point your program at the Cabi.Chat Bot API with that token. Every request goes to https://api.cabi.chat/bot<token>/<method>, the same shape as Telegram's:

GET  https://api.cabi.chat/bot<token>/getMe
GET  https://api.cabi.chat/bot<token>/getUpdates?timeout=50
POST https://api.cabi.chat/bot<token>/sendMessage   {"chat_id": <chat id>, "text": "…"}

Receive updates by long polling or by a webhook you set with setWebhook, and answer with the usual methods. Supported methods: Spectral — plugins via the Telegram bot emulator

Files: getFile gives a file_path; download it from https://api.cabi.chat/file/bot<token>/<file_path>.

3. Talk. Each person who opens the widget gets a room with it: a private chat with your widget, as in Telegram. Their messages arrive as updates with chat.type private and chat.id equal to the person's user id; what your program sends to that chat appears in the room.

Opening a room: API pipeline: Set up a Cabi.Chat widget that Cabi.Chat's AI runs, step 4.

Example: Claude Code

Claude Code can talk to you through a Cabi.Chat widget: it runs on your own machine under your own sign-in, and Cabi.Chat is only the chat surface. The official Claude Code Telegram channel plugin speaks the Telegram Bot API, so it works with any Telegram-compatible Bot API root, https://api.cabi.chat included. The plugin setting that points it at another Bot API root is pending upstream; once your plugin version has it:

  1. In Claude Code: /plugin install telegram@claude-plugins-official, then /telegram:configure <widget token>.
  2. Set the plugin's Bot API root to https://api.cabi.chat.
  3. Start Claude Code with the channel: claude --channels plugin:telegram@claude-plugins-official.
  4. Open the widget's room on Cabi.Chat and write to it; pair with /telegram:access pair <code> and lock it with /telegram:access policy allowlist, so only you can drive your session.

Your room with the widget is a private chat, so pairing, commands and permission prompts work as they do with a Telegram bot; with topics_in_private on, you can keep separate threads in it.

Keep the widget Private so only you can open its room.

Rules

API surface

Endpoint Purpose FE AI / oracle
POST /v0/my/oracles Create the widget, get its token once yes (token: no) your token
POST /v0/my/oracles/{nonce}/regenerate-token A new token; the old one stops no your token
PATCH /v0/my/oracles/{nonce} Title, project, visibility, agenda, topics_in_private yes yes
https://api.cabi.chat/bot<token>/<method> Receive and answer as the widget — your program
DELETE /v0/my/oracles/{nonce} Delete yes rarely

Mentioned