Skip to content

Support multi Telegram bots for gateway routing and send_message #10452

@yimwoo

Description

@yimwoo

Summary

Hermes gateway currently assumes a single Telegram bot/account. In real deployments, it is often useful to run multiple Telegram bots side-by-side (for example a primary assistant bot plus a dev/team bot) and to route outbound messages explicitly through the intended account.

This issue proposes backward-compatible multi-account Telegram support across config loading, gateway startup, channel directory resolution, and send_message routing.

Problems observed

  • TELEGRAM_BOT_TOKEN supports only one Telegram account.
  • Gateway startup creates only one Telegram adapter.
  • send_message cannot explicitly target a secondary Telegram account.
  • Channel directory resolution assumes a single telegram namespace, so account-specific label resolution is not possible.
  • Runtime status / reconnect bookkeeping assumes adapter keys are enum platform values rather than account-qualified labels.

Proposed behavior

  • Preserve existing single-account behavior.
  • Add env/config support for extra Telegram accounts, e.g. TELEGRAM_BOT_TOKEN_DEVTEAM.
  • Start one adapter per configured Telegram account.
  • Allow explicit outbound targeting via syntax like:
    • telegram:devteam:-1001234567890
    • telegram:devteam:-1001234567890:17585
    • telegram:devteam:Alerts Room
  • Treat account-qualified directory namespaces as telegram[devteam] internally while keeping fallback to base telegram entries.
  • Ensure reconnect/runtime-status bookkeeping works with string adapter keys like telegram[devteam].

Acceptance criteria

  • Existing telegram:* sends continue to work unchanged.
  • Extra Telegram accounts can be configured from env/config.
  • Gateway starts primary + extra Telegram adapters.
  • send_message resolves and sends via the correct account-specific token/config.
  • Channel name resolution works for both telegram and telegram[account] namespaces.
  • Tests cover env parsing, runner startup, directory resolution, and send routing.

Validation performed locally

  • Targeted test suite passed locally
  • Live outbound sends were verified successfully through two distinct Telegram bot identities.

Notes

This is intended to be additive and backward-compatible. Existing single-account Telegram setups should continue to work without any configuration changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions