Repository navigation
Add Telegram channel adapter - #20
Merged
5 commits merged intoOct 13, 2026
Merged
5 commits merged into
5 commits merged into
Conversation
Long polling by default with offset holdback, optional secret-checked webhook mode, Markdown converted to Telegram entities, typing keepalive, inline-keyboard rich replies, document uploads and bounded downloads.
This pull request was closed.
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.
Coming from this LinkedIn thread.
This adds telegram support. I've been using my own private setup for Telegram comms, so I had most of the impl down, tried and tested.
Left streaming out so I could keep this as close to existing interfaces as possible.
Tested live with all msg types on my phone apart from the automated tests.

LLM generated summary:
AgentChat can now receive messages and send confirmed replies through Telegram bots. The adapter lives in its own
agentchat.channels.telegrampackage and uses the existing aiohttp dependency (telegram = []extra). It comes with a setup guide and a framework-free echo example.TELEGRAM_WEBHOOK_URLandTELEGRAM_WEBHOOK_SECRET. It checks the secret header in constant time, returns 503 when full, and exposescreate_app()for host-owned servers./command@bot, atext_mention, or a reply to the bot.reply: Markdown converted to Telegram formatting.reply_rich: nativereply_markup, e.g.RichReply(text=..., blocks=({"inline_keyboard": [...]},)).set_status: typing indicator, kept alive while working.upload_files: viasendDocument.download_attachment: viagetFile, bounded bymax_bytes.TelegramError(RuntimeError)witherror_code,descriptionandretry_after.docs/providers.mdspecifies, so there is no automatic 429 retry.ValueErrorbefore any send.Design decisions
Formatting: Markdown becomes Telegram
entities, neverparse_mode.**and backticks.parse_mode(MarkdownV2/HTML) corrupts code silently: the underscore inget_user_data()is read as italic, and the message renders asgetuserdata()with no error.rendering.pyis a small stdlib-only converter that emits entity offsets in UTF-16 code units:__is not a delimiter, so__init__.pysurvives intact.text_link.Streaming: not included.
sendMessageDraft(Bot API 9.3, open to all bots since 9.5).sendMessage.Core changes
None to runtime modules. In the shared contract suite,
test_providers.pygains a Telegram harness.test_optional_capability_fallbacksbecomes capability-aware: each harness declares the protocols it implements, missing protocols must still fall back, and implemented ones must passisinstance. The four existing adapters keep every assertion they had.Validation
ruff check .passes.python -m pytest: 463 passed on Python 3.11, the CI version, and on 3.14. Coverage includes:setWebhooksendDocumentupload /getFiledownload /max_bytesround trip.