How It Works
Every incoming message flows through a structured pipeline: Concurrency is controlled by a semaphore — multiple messages can be processed in parallel up tomax_concurrent_requests. Errors at any step trigger on_error hooks and send a configurable error message to the user.
Quick Example
Deploy an agent to Telegram in a few lines:Lifecycle
Starting
Stopping
The interface shuts down gracefully onKeyboardInterrupt or when stop() is called. All active connections and resources are cleaned up.
BaseInterface Constructor
All interfaces accept these parameters:The Definable agent that processes messages.
Platform-specific parameters passed directly (e.g.,
bot_token, mode, allowed_user_ids). See each interface’s reference for available parameters.Custom session manager. A default one is created if not provided.
List of hooks to attach. Can also be added later with
.add_hook().Cross-platform identity resolver. Maps platform user IDs to canonical user IDs for shared memory. See Identity Resolution.
Common Parameters
All interfaces accept these base parameters as keyword arguments:| Parameter | Type | Default | Description |
|---|---|---|---|
platform | str | "" | Platform identifier |
max_session_history | int | 50 | Maximum messages kept in session history |
session_ttl_seconds | int | 3600 | Session expiry time (1 hour) |
max_concurrent_requests | int | 10 | Max simultaneous agent calls |
error_message | str | "Sorry, something went wrong..." | Message sent to user on error |
typing_indicator | bool | True | Show typing indicator while processing |
max_message_length | int | 4096 | Max characters per outgoing message |
rate_limit_messages_per_minute | int | 30 | Per-user rate limit |
Adding Hooks
Chain hooks with.add_hook():
Key Concepts
Sessions
Automatic per-user session management with history, state, and TTL expiry.
Hooks
Intercept messages and responses with composable hook functions.
Telegram
Deploy to Telegram with polling or webhooks, media support, and access control.
Discord
Deploy to Discord with guild/DM support, attachments, and access control.
Slack
Deploy to Slack with Socket Mode, Block Kit interactions, and slash commands.
WebSocket
Real-time bidirectional communication via JSON WebSocket protocol.
Connect to WhatsApp via the Twilio WhatsApp API.
IMAP polling + SMTP sending with thread tracking.
Call (Voice)
Voice calls via Twilio ConversationRelay.
Identity
Map users across platforms to a single canonical identity.
Multi-Interface
Run multiple interfaces concurrently with automatic restart.
Custom Interfaces
Build your own interface for any messaging platform.
Usage Examples
Telegram Bot
Step-by-step: agent with tools, memory, and voice notes.
Discord Bot
Step-by-step: agent with tools and persistent memory.
Slack Bot
Step-by-step: agent with tools and slash commands.
Multi-Platform
Serve one agent across Telegram, Discord, and Slack.