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.
Configuration for the interface. Use a platform-specific config like
TelegramConfig.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.
InterfaceConfig
Base configuration shared by all interfaces:| 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 |
AgentConfig, it is immutable. Use with_updates() to create a modified copy:
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.
Signal
Deploy to Signal with auto-managed Docker or bring-your-own container.
Identity
Map users across platforms to a single canonical identity for shared memory.
Multi-Interface
Run multiple interfaces concurrently with automatic restart and graceful shutdown.
Custom Interfaces
Build your own interface for any messaging platform.