← Back to PRs

#19869: feat(telegram): add disableWebPagePreview option

by bip-bup-bip-bup open 2026-02-18 07:58 View on GitHub →
channel: telegram agents size: XS
## 🎯 Overview Add support for disabling web page previews in Telegram messages via the `disableWebPagePreview` parameter. ## 🔧 Changes - **TelegramSendOpts**: Added `disableWebPagePreview?: boolean` parameter - **Send Logic**: Support `disable_web_page_preview` in text, media, and poll messages - **Message Tool**: Added TypeBox validation for the new parameter - **Telegram Actions**: Wire parameter through to `sendMessageTelegram` ## 📖 Usage ```javascript // Using message tool message({ action: 'send', target: '@username', message: 'Check out https://example.com - no preview!', disableWebPagePreview: true }) // Using telegram actions directly await sendMessageTelegram('chat_id', 'Text with https://link.com', { disableWebPagePreview: true }) ``` ## 🧪 Testing - [x] Parameter correctly typed in TelegramSendOpts - [x] Logic added to all send methods (text, media, polls) - [x] TypeBox validation schema updated - [x] Integration through telegram actions verified ## 📝 Notes This implements the standard Telegram Bot API `disable_web_page_preview` parameter, allowing users to send messages with links without showing preview cards. Perfect for weekly digest messages where link previews would clutter the chat! 📰 <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a `disableWebPagePreview` option to suppress link previews in Telegram messages, wiring it through the message tool schema, telegram actions, and the send module. - **TypeScript type error in poll path**: `sendPollTelegram` references `opts.disableWebPagePreview` but its `TelegramPollOpts` type does not include this field — this will fail `pnpm build` / `pnpm tsgo`. - **Invalid API parameter for media and polls**: `disable_web_page_preview` is only valid for `sendMessage` in the Telegram Bot API. Applying it to `sendPhoto`, `sendVideo`, `sendAnimation`, `sendDocument`, `sendAudio`, `sendVoice`, `sendVideoNote`, and `sendPoll` is incorrect — these methods don't generate link previews. - **Inconsistent with existing pattern**: The codebase already uses the modern `link_preview_options: { is_disabled: true }` parameter (Bot API 7.0+). This PR adds the deprecated `disable_web_page_preview` field, creating two competing mechanisms for the same behavior. - **Ad-hoc test file**: `test-disable-preview.cjs` is a manual smoke test not integrated with the vitest suite. It should be removed and replaced with proper test cases in `src/telegram/send.test.ts`. <h3>Confidence Score: 2/5</h3> - This PR has a TypeScript compilation error and applies an API parameter to methods that don't support it; it needs revisions before merging. - Score of 2 reflects a confirmed type error in the poll path that would break the build, incorrect application of `disable_web_page_preview` to media and poll API methods, and an uncommitted test file at the repo root. The text message path works functionally but uses a deprecated parameter. - `src/telegram/send.ts` needs the most attention: the `disable_web_page_preview` spread should be removed from `mediaParams` and `pollParams`, and should use `link_preview_options` instead in the text message path. `test-disable-preview.cjs` should be removed entirely. <sub>Last reviewed commit: eb2c2c2</sub> <!-- 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)) <!-- /greptile_comment -->

Most Similar PRs