Skip to content

feat(telegram): add thread_profiles config for per-topic Hermes profile routing - #55632

Closed
mateuor2d2 wants to merge 1 commit into
NousResearch:mainfrom
mateuor2d2:feat/thread-profiles
Closed

feat(telegram): add thread_profiles config for per-topic Hermes profile routing#55632
mateuor2d2 wants to merge 1 commit into
NousResearch:mainfrom
mateuor2d2:feat/thread-profiles

Conversation

@mateuor2d2

Copy link
Copy Markdown

Summary

Adds support for routing Telegram forum topics to specific Hermes profiles via a thread_profiles mapping in the Telegram adapter extra config.

Motivation (Cima20Nest)

This enables running a single Telegram bot that routes different forum topics to different Hermes profiles, each with its own SOUL, skills, and memories. Use case: a project management group where #jornada routes to a development profile, #business routes to a strategy profile, #security routes to a whitehat profile, etc.

Config example

telegram:
  extra:
    thread_profiles:
      "-1003528109556:12345": "business"
      "-1003528109556:67890": "jornada-dev"

How it works

When a message arrives in a forum topic (supergroup with is_forum=True), the adapter checks the (chat_id:thread_id) composite key first, then falls back to thread_id alone. If a match is found, SessionSource.profile is populated, and the gateway routes the session to that profile.

Changes

  • 1 file changed, 12 insertions
  • plugins/platforms/telegram/adapter.py: parse thread_profiles from config.extra, resolve profile in _source_from_message_for_auth

No new dependencies. No breaking changes. SessionSource.profile already exists and is used by the webhook adapter.

…le routing

Adds support for routing Telegram forum topics to specific Hermes profiles
via a thread_profiles mapping in the Telegram adapter extra config.

Usage in config.yaml:
  telegram:
    extra:
      thread_profiles:
        "-1003528109556:12345": "business"
        "12345": "jornada-dev"

When a message arrives in a forum topic (supergroup with is_forum=True),
the adapter checks the (chat_id:thread_id) key first, then falls back to
thread_id alone. If a match is found, the SessionSource.profile field is
populated, and the gateway routes the session to that profile.

This enables Cima20Nest-style multi-profile routing through a single
Telegram bot.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter comp/plugins Plugin system and bundled plugins labels Jun 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Competing implementation for Telegram forum-topic → Hermes-profile routing. Cluster: #47236 (config.extra.topic_profiles, earlier, same adapter mechanism), broader #18510 (touches gateway core / env_loader / runtime_provider), and feature issues #10143 / #4321. This PR uses a thread_profiles map with a composite chat_id:thread_id key. Related, not a duplicate — same goal, different scope/key shape; a maintainer should pick the canonical approach (#47236 is the earliest narrow entrant).

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: LGTM

Adds thread_profiles config for per-topic Hermes profile routing in Telegram forum/DM topics.

✅ Looks Good

  • Clean implementation: thread-to-profile routing via config.extra.thread_profiles
  • Supports both full key (chat_id:thread_id) and partial match (thread_id alone)
  • Single file, well-scoped feature addition
  • Follows existing Telegram adapter patterns

Reviewed by Hermes Agent

@mateuor2d2 mateuor2d2 closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants