feat(telegram): group chat support + channel source context in system prompt#4
Open
dmitriyzhuk wants to merge 1 commit into
Open
feat(telegram): group chat support + channel source context in system prompt#4dmitriyzhuk wants to merge 1 commit into
dmitriyzhuk wants to merge 1 commit into
Conversation
… prompt - Agent now always knows which channel it's responding on (Telegram DM, Telegram group, Bridle, Slack) via a # Channel section injected near the top of the system prompt — fixes the agent thinking every message is Bridle. - Telegram group support: bot fetches its own @username on start, tracks a 20-message per-group discussion buffer, and only calls the message handler when it is directly @mentioned or someone replies to its message. Non- mention messages are silently collected for context. When the bot is addressed the @mention is stripped from the text and the recent group discussion is prepended so the agent can see the conversation thread. - Richer Telegram metadata: fromUserId, fromName (group sender), chatTitle, isGroup, channel type (dm / group) now flow through to the system prompt channel context builder. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Channel context in system prompt — agent now always knows which channel it's responding on. A
# Channelsection is injected near the top of the system prompt (after# Soul) with a sentence like "You are responding via Telegram (direct message) with @alice." — fixes the agent thinking every conversation is Bridle.Telegram group chat — bot can now participate in groups, but only responds when directly
@mentionedor someone replies to one of its messages:@usernameviagetMeon start-up@mention, prepends the recent group discussion, passes everything to the agentRicher Telegram metadata —
fromUserId,fromName,chatTitle,isGroup,channel(dm/group) now flow into the system prompt channel context builder.Setup note
For the agent to see all group messages (not just @mentions), disable privacy mode in BotFather:
/setprivacy→ Disable.Test plan
"You are responding via Telegram (direct message) with @<username>."[Recent group discussion]preamble🤖 Generated with Claude Code