← Back to PRs

#6084: Add dynamic Telegram agent routing for DM and groups

by Alfonsxh open 2026-02-01 08:11 View on GitHub →
channel: telegram
## Summary - add dynamic Telegram agent routing for DM and groups via config - create per-user/per-group agent and workspace IDs - extend Telegram message context to use dynamic agent session keys - add coverage for dynamic agent routing in tests ## Config - new key: channels.telegram.dynamicAgents = off|dm|group|dm+group <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new Telegram config knob (`channels.telegram.dynamicAgents`) to route inbound Telegram messages to dynamically generated per-user (DM) and/or per-group agents, and extends Telegram message context/session key generation accordingly. It also updates UI schema hints and adds tests covering the new routing behavior. Key integration points are `buildTelegramMessageContext` (now accepts a merged `telegramCfg` and may bypass `resolveAgentRoute` when dynamic routing is enabled) and the Telegram message processor which passes the merged Telegram config through to context building. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but the dynamic-routing path duplicates session-key construction and may drift from the canonical router behavior. - Most changes are additive and covered by tests, but the dynamic route constructs `sessionKey`/`mainSessionKey` manually and hardcodes `matchedBy`, which can cause subtle behavior divergence from `resolveAgentRoute` over time. Minor schema/default and comment-language consistency issues remain. - src/telegram/bot-message-context.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs