Skip to main content
The B-Bot SDK (@beyond-bot-ai/sdk) is the official way to interact with the B-Bot Platform. It provides a type-safe interface to manage Distribution Channels (Assistants), Threads, and Runs, built on top of the LangGraph SDK but adapted for B-Bot’s terminology.

NPM Package

View on NPM

Installation

Quick Start

Initialize the client with your B-Bot API Key. The SDK is pre-configured to connect to the B-Bot API.

Getting Your API Key

  1. Go to B-Bot Hub
  2. Navigate to SettingsAPI Keys
  3. Click Create New API Key
  4. Copy the key (starts with bbot_)
  5. Store it securely (treat it like a password!)
Never commit your API key to version control. Use environment variables:

Core Concepts

1. Distribution Channels

In B-Bot, AI Assistants are exposed as Distribution Channels. You can search, retrieve, and manage them using the client.distributionChannels property.

2. Threads

Threads persist the state of a conversation. Every interaction happens within a thread.
Important: B-Bot sends cumulative content in messages/partial events (e.g., “Hello”, “Hello!”, “Hello! How”), not individual tokens. Your onMessage callback should replace the content, not append it.
The SDK includes a powerful Streaming Handler (client.streamRun) that simplifies processing real-time events like token streaming, tool execution, and state updates.

Manual Streaming (Advanced)

If you need lower-level control over the stream:

State Management (Todos & Files)

The SDK automatically extracts structured data like Todos and Files generated by the AI.

Debugging

If onMessage is not being called or you’re not receiving events, enable debug mode:
This will log:
  • Every chunk received from the stream
  • Event types and data structures
  • Content extraction process
  • Total chunks processed

Common Pitfalls

1. Missing entity_id

B-Bot requires entity_id in the initial state. Always extract it from the channel config:

2. Using channel_id instead of assistant_id

The API returns assistant_id, not channel_id. Use channel.assistant_id.

3. Appending cumulative content

B-Bot sends the full message so far in each chunk. Always replace content when isCumulative=true.

Features

  • Native Terminology: Uses client.distributionChannels instead of client.assistants.
  • Streaming Handler: Built-in streamRun helper for easy real-time UI updates.
  • State Extraction: Automatically extracts Todos and Files from stream events.
  • Auto-Configuration: Pre-configured for api.b-bot.space.
  • Type Safety: Full TypeScript support.
  • Cumulative Streaming: Properly handles B-Bot’s cumulative content streaming.

License

MIT