fix(telegram): add document message support (docx/pdf/etc)#2069
Merged
RockChinQ merged 1 commit intolangbot-app:masterfrom Mar 21, 2026
Merged
fix(telegram): add document message support (docx/pdf/etc)#2069RockChinQ merged 1 commit intolangbot-app:masterfrom
RockChinQ merged 1 commit intolangbot-app:masterfrom
Conversation
The Telegram adapter only handles TEXT, COMMAND, PHOTO, and VOICE messages. Document files (docx, pdf, etc.) sent by users are silently dropped because: 1. MessageHandler filters lack filters.Document.ALL 2. target2yiri() has no message.document branch 3. yiri2target() has no platform_message.File branch 4. send_message() has no 'document' component handler Changes: - Add filters.Document.ALL to the MessageHandler filter set - Add message.document parsing in target2yiri() → platform_message.File - Add platform_message.File handling in yiri2target() → document component - Add 'document' type handling in send_message() via bot.send_document() This allows Telegram document messages to flow through the existing PreProcessor and Dify file upload pipeline, consistent with how other adapters (Lark, KOOK, Discord, WeCom) already handle files. Closes langbot-app#2065
RockChinQ
approved these changes
Mar 21, 2026
Contributor
Author
|
Is there a developer group? We would like to join and have the opportunity to communicate with others. |
Member
|
@sliverp join in QQ: 1032327138 |
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.
Problem
The Telegram adapter cannot receive document messages (docx, pdf, etc.) from users. While photos and voice messages work correctly, documents are silently dropped. This means file-based workflows (e.g., Dify document processing) cannot be triggered from Telegram.
Root Cause
Four gaps in the Telegram adapter:
__init__): OnlyTEXT | COMMAND | PHOTO | VOICE— missingDocument.ALLtarget2yiri): Nomessage.documentbranch — documents are ignoredyiri2target): Noplatform_message.Filebranch — cannot convert File components for Telegramsend_message): Nodocumentcomponent type — cannot send documentsFix
telegram.py:__init__filters.Document.ALLto MessageHandlertelegram.py:target2yirimessage.document→platform_message.Fileconversion (downloads file via Bot API, extracts name/size/mime_type)telegram.py:yiri2targetplatform_message.File→{type: "document"}conversiontelegram.py:send_messagedocumenttype handling viabot.send_document()This is consistent with how other adapters (Lark, KOOK, Discord, WeCom) already handle file messages.
Testing
platform_message.Fileand forwarded to the pipelinebot.send_document()with proper filenameCloses #2065