← Back to PRs

#15975: feat(telegram): add Business Mode for personal chat access

by scomma open 2026-02-14 04:13 View on GitHub →
channel: telegram agents stale size: L
## Summary - Adds Telegram Business Mode integration — passive ingestion of the operator's personal Telegram chats via the Business API - Messages stored locally in JSONL (`{stateDir}/telegram-business/{accountId}/chats/{chatId}/messages.jsonl`) - New `telegram_business` agent tool with `list_chats`, `get_messages`, `search`, and `send` actions - Handles `business_connection`, `business_message`, `edited_business_message`, and `deleted_business_messages` update types - Config: `channels.telegram.business.enabled: true` to activate This is a data-source integration (like gog for Gmail), not a real-time channel. Messages are passively stored and queried on demand. The agent is NOT woken on incoming business messages. ## Test plan - [x] Enable Business Mode in @BotFather - [x] Connect bot in Telegram app → Settings → Telegram Business → Chatbots - [x] Verify `business_connection` stored to `connections.json` - [x] Send messages in personal chat → verify JSONL ingestion with correct direction detection - [x] Test `telegram_business action=list_chats` via agent - [x] Test `telegram_business action=get_messages` via agent - [x] Test `telegram_business action=search` via agent - [x] Test incoming message direction detection (contact sends to operator) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds Telegram Business Mode integration allowing passive ingestion of operator's personal Telegram chats via the Business API. Messages are stored locally in JSONL format under `{stateDir}/telegram-business/{accountId}/chats/{chatId}/messages.jsonl` and accessed on-demand through a new `telegram_business` agent tool. **Key changes:** - Created new business integration module in `src/telegram/business/` with connection store, message store, and event handlers - Handles `business_connection`, `business_message`, `edited_business_message`, and `deleted_business_messages` update types - New agent tool supports `list_chats`, `get_messages`, `search`, and `send` actions - Config: enable with `channels.telegram.business.enabled: true` - Includes pre-reset hook feature from merged branch (allows agent wrap-up before session reset) **Implementation quality:** - Direction detection logic correctly identifies incoming vs outgoing messages by comparing `from.id` with `chat.id` - Message deduplication properly handles edits and deletions - Error handling uses try-catch with graceful fallbacks - Sequential processing ensured via `getTelegramSequentialKey` updates <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with minor considerations around testing and potential file system growth - The implementation is well-structured with proper error handling, sequential processing guarantees, and clean separation of concerns. Message deduplication and direction detection logic are sound. The code follows project conventions (TypeScript strict typing, proper error handling). However, the score is not a perfect 5 due to: (1) no test coverage for the new business integration, (2) no built-in limits on JSONL file growth despite config options for `maxMessagesPerChat` and `maxAgeDays` being defined but unused, and (3) the feature merges pre-reset hook changes that were already in main, making the diff slightly larger than the feature alone. - Pay attention to `src/telegram/business/message-store.ts` regarding potential file growth - the config defines retention limits but they're not enforced in the append operations <sub>Last reviewed commit: e93ccd3</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs