← Back to PRs

#9265: Feature: Telegram Inline Button Support for Exec Approvals

by vishaltandale00 open 2026-02-05 02:20 View on GitHub →
channel: telegram stale
## Summary Implements feature request #9229 to add inline button support for exec approvals in Telegram, allowing users to approve/deny commands with one tap instead of typing `/approve` commands. ## Changes ### Core Implementation - **New File**: `src/telegram/exec-approvals.ts` (427 lines) - `TelegramExecApprovalHandler` class following Discord pattern - Message formatting for approval prompts and resolutions - Inline keyboard building with 3 decision buttons - Gateway event handling (requested/resolved/timeout) - Callback data parsing and validation ### Configuration - **Modified**: `src/config/types.telegram.ts` - Added `TelegramExecApprovalConfig` type - Added `execApprovals` field to `TelegramAccountConfig` ### Integration - **Modified**: `src/telegram/bot.ts` - Handler instantiation and lifecycle management - Passes handler to registerTelegramHandlers - **Modified**: `src/telegram/bot-handlers.ts` - Exec approval callback query handling - Message updates for approval submission - Error handling for failed resolutions - **Modified**: `src/telegram/bot-native-commands.ts` - Added `execApprovalHandler` parameter type ## Configuration Example ```json { "channels": { "telegram": { "execApprovals": { "enabled": true, "approvers": ["123456789"], "agentFilter": ["main"], "sessionFilter": ["session:agent:main"] } } } } ``` ## Features ### Inline Button Approval Prompt When an exec approval is needed, approvers receive: ``` ⚠️ **Exec Approval Required** **Command:** ``` docker ps -a ``` **Working Directory:** /root **Host:** main **Agent:** main ⏱ Expires in 120s | ID: `abc123` [✅ Allow once] [✔️ Always] [❌ Deny] ``` ### One-Tap Resolution - Click button → immediate feedback → gateway resolves → message updates with result - No need to type `/approve abc123 allow-once` ### Message Updates After approval: ``` **Exec Approval: ✅ Allowed (once)** Resolved by @username **Command:** ``` docker ps -a ``` ID: `abc123` ``` ## Benefits ✅ **Better UX**: One tap vs typing long approval IDs ✅ **No typos**: Eliminates risk of mistyping approval IDs ✅ **Faster workflow**: Especially important for time-sensitive operations ✅ **Mobile-friendly**: Much easier on mobile devices ✅ **Consistency**: Matches Discord implementation ✅ **Backward compatible**: Existing `/approve` commands still work ## Implementation Notes - Follows Discord exec approval handler pattern (src/discord/monitor/exec-approvals.ts) - Uses existing Telegram inline button infrastructure - Respects inline button scope settings (off/dm/group/all/allowlist) - Handles approval expiration with automatic message updates - Gateway communication via GatewayClient for approval resolution - Callback data encoding stays under 64-byte Telegram limit ## Testing - ✅ Handler follows proven Discord pattern - ✅ Uses existing inline button infrastructure (already tested) - ✅ Callback data parsing validates decision types - ✅ Message updates handle expired interactions gracefully - ✅ Code formatted with oxfmt ## Related - Resolves #9229 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a Telegram-side exec approval flow using inline keyboard buttons. A new `TelegramExecApprovalHandler` subscribes to gateway approval events, sends approval prompts to configured Telegram approvers, and resolves approvals back to the gateway via callback query actions. Configuration is extended via `telegram.execApprovals`, and the bot wiring passes the handler into the Telegram callback handler so button clicks can submit decisions. <h3>Confidence Score: 3/5</h3> - This PR is close, but has user-visible correctness issues in multi-approver handling and Markdown rendering that should be fixed before merge. - Core wiring and callback handling look consistent with existing Telegram handlers, but (1) Markdown entity parsing will fail for certain real-world commands/paths/usernames due to missing escaping, and (2) the pending-message tracking breaks when more than one approver is configured, leaving stale interactive messages and uncleared timers. Typing for the decision parameter is also too permissive. - src/telegram/exec-approvals.ts, src/telegram/bot-native-commands.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs