-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Problem
Currently, Spacebot only supports a single Telegram bot token per instance. When running multiple agents that each need their own Telegram bot identity (separate BotFather tokens), the only option is to run multiple Spacebot processes — one per bot.
This adds unnecessary operational overhead (separate containers, separate configs, separate data dirs) for what should be a single multi-agent deployment.
Current Architecture (blockers)
-
Config model —
MessagingConfig.telegramisOption<TelegramConfig>, not aVecor map.[messaging.telegram]can only appear once in TOML. -
Adapter name collision —
TelegramAdapter::name()returns the hardcoded string"telegram". TheMessagingManagerstores adapters in aHashMap<String, ...>keyed by this name, so registering a second adapter overwrites the first. -
Source-based response routing — Inbound messages are tagged with
source: "telegram". Outbound responses are routed by looking upmessage.sourcein the adapter map. No way to distinguish which bot received the message.
Proposed Solution
Allow named Telegram adapter instances, similar to how you might configure multiple of any service:
[messaging.telegram.community]
enabled = true
token = "env:TELEGRAM_TOKEN_COMMUNITY"
[messaging.telegram.personal]
enabled = true
token = "env:TELEGRAM_TOKEN_PERSONAL"With bindings referencing the specific instance:
[[bindings]]
agent_id = "community-bot"
channel = "telegram.community"
[[bindings]]
agent_id = "personal-bot"
channel = "telegram.personal"Changes needed
- config.rs: Change
telegram: Option<TelegramConfig>totelegram: HashMap<String, TelegramConfig>(orBTreeMap), add backward compat for the unnamed single-token form - telegram.rs: Accept a name/id parameter in
new(), use it inname()(e.g."telegram.community") and as thesourcefield on inbound messages - main.rs: Loop over Telegram configs and register each as a separate adapter
- Bindings:
channelfield matches the qualified adapter name - TelegramPermissions: Per-adapter rather than shared
Use Case
Running two Telegram bots (each with distinct bot identities/usernames) bound to different agents in the same Spacebot instance. Currently requires two separate containers as a workaround.