#22434: feat(telegram): support sending original quality images
channel: telegram
size: XS
Cluster:
Messaging Platform Improvements
Add mediaOptimize config option to Telegram channel. When mediaOptimize is set to false, images are sent as documents instead of compressed photos to preserve original quality.
- Add asFile option to TelegramSendOpts
- Update image sending logic to use sendDocument when asFile is true
- Add mediaOptimize option to TelegramAccountSchemaBase
- Update outbound adapter to read config and pass asFile flag
Closes #22014
## Summary
- Problem: Images sent via Telegram are compressed to 800px + quality 40, resulting in significant quality loss
- Why it matters: Users need to send high-quality images (posters, designs) but cannot preserve original quality
- What changed: Added mediaOptimize config option - when set to false, images are sent as Documents (no compression)
- What did NOT change: Default behavior remains the same (compression enabled by default)
## Change Type (select all)
- [x] Feature
## Scope (select all touched areas)
- [x] Integrations
## Linked Issue/PR
- Closes #22014
## User-visible / Behavior Changes
- New config option: `channels.telegram.mediaOptimize`
- When set to `false`, images are sent as Documents (files) to preserve original quality
## Security Impact (required)
- New permissions/capabilities? No
- Secrets/tokens handling changed? No
- New/changed network calls? No
- Command/tool execution surface changed? No
- Data access scope changed? No
## Human Verification (required)
- Verified scenarios: Code implemented and pushed to fork
- Edge cases checked: Default behavior unchanged (mediaOptimize defaults to true)
- What you did NOT verify: Actual runtime testing
## Compatibility / Migration
- Backward compatible? Yes
- Config/env changes? Yes (new optional config option)
- Migration needed? No
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a `mediaOptimize` config option to the Telegram channel that, when set to `false`, sends images as documents (via `sendDocument`) instead of compressed photos (via `sendPhoto`), preserving original quality. The implementation touches the Zod schema, the outbound adapter (both `sendMedia` and `sendPayload` paths), and the send function's media routing logic.
- The Zod schema in `TelegramAccountSchemaBase` was updated, but the corresponding manual TypeScript type `TelegramAccountConfig` in `src/config/types.telegram.ts` was **not updated** — this will cause a TypeScript compilation error when accessing `resolved.config.mediaOptimize`.
- The import of `resolveTelegramAccount` in the outbound adapter uses `"openclaw/plugin-sdk"` instead of a relative import, which is inconsistent with all other core `src/` files.
- The `asFile` handling in `send.ts` is clean and correctly scoped to the `kind === "image"` branch only.
<h3>Confidence Score: 2/5</h3>
- This PR will likely fail TypeScript compilation due to a missing type update, blocking mergeability.
- The core feature logic is sound, but the `TelegramAccountConfig` type in `src/config/types.telegram.ts` was not updated to include `mediaOptimize`, which means `resolved.config.mediaOptimize` will be a type error. This is a build-blocking issue. The import convention issue is minor but worth fixing.
- Pay close attention to `src/config/types.telegram.ts` (missing type update) and `src/channels/plugins/outbound/telegram.ts` (import convention).
<sub>Last reviewed commit: f501418</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#14057: feat(telegram): add ignoreMediaTypes config to skip specific inboun...
by pavelsamoylenko · 2026-02-11
82.5%
#21898: fix(telegram): auto-detect captionable messages for editMessageCaption
by ptrkstr · 2026-02-20
82.2%
#18842: feat(telegram): add /imagequality command for uncompressed image de...
by frankekn · 2026-02-17
81.7%
#21029: Feature/telegram bot avatar clean
by aleonnet · 2026-02-19
81.3%
#19942: feat(telegram): configurable SSRF policy for media fetch
by onewesong · 2026-02-18
80.9%
#18915: fix(telegram): pass video width/height to sendVideo to prevent portra…
by storyarcade · 2026-02-17
80.3%
#19399: telegram: fix MEDIA false positives and partial final drop
by HOYALIM · 2026-02-17
80.1%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
78.7%
#21309: feat(telegram): support outbound media groups (albums) via sendMedi...
by smysle · 2026-02-19
78.6%
#21276: fix(telegram): stabilize partial finalization and MEDIA dedupe (AI-...
by HOYALIM · 2026-02-19
78.2%