Skip to content

fix(telegram): set parse_mode for markdown messages#245

Merged
haydenbleasel merged 2 commits intomainfrom
fix/telegram-markdown-parse-mode
Mar 16, 2026
Merged

fix(telegram): set parse_mode for markdown messages#245
haydenbleasel merged 2 commits intomainfrom
fix/telegram-markdown-parse-mode

Conversation

@bensabic
Copy link
Copy Markdown
Contributor

postMessage and editMessage only set parse_mode when a card was present, causing { markdown: "..." } messages to render as plain text with visible formatting characters. Now also sets parse_mode to "Markdown" when the message has a markdown field.

Closes #226

postMessage and editMessage only set parse_mode when a card was present,
causing markdown messages to render as plain text with visible formatting
characters. Now also sets parse_mode when the message has a markdown field.

Closes #226
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 6:54pm
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 6:54pm

Comment thread packages/adapter-telegram/src/index.ts Outdated
…editMessage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@haydenbleasel haydenbleasel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Extracted a resolveParseMode helper that both postMessage and editMessage now use. Thanks for the catch! 🙌

@haydenbleasel haydenbleasel merged commit 1d36004 into main Mar 16, 2026
9 of 10 checks passed
@haydenbleasel haydenbleasel deleted the fix/telegram-markdown-parse-mode branch March 16, 2026 18:54
Koshkoshinsk added a commit to Koshkoshinsk/chat that referenced this pull request Apr 12, 2026
Since vercel#245, the Telegram adapter hardcodes parse_mode: "Markdown" whenever
the caller passes { markdown: ... }. Telegram considers legacy Markdown a
deprecated mode and it has no escape support, so callers can hit
"Bad Request: can't parse entities" with no way to recover other than
dropping the message.

Add an optional parseMode field to TelegramAdapterConfig that lets callers
choose between "Markdown" (default, backward compatible), "MarkdownV2",
"HTML", or "none" (omit parse_mode entirely as a safety valve).

The converter is unchanged; this PR only exposes a knob so callers whose
upstream renderer produces MarkdownV2/HTML/plain-text can tell the adapter
not to ask Telegram to parse legacy Markdown entities.
Koshkoshinsk added a commit to Koshkoshinsk/chat that referenced this pull request Apr 12, 2026
Since vercel#245, the Telegram adapter hardcodes parse_mode: "Markdown" whenever
the caller passes { markdown: ... }. Telegram considers legacy Markdown a
deprecated mode and it has no escape support, so callers can hit
"Bad Request: can't parse entities" with no way to recover other than
dropping the message.

Add an optional parseMode field to TelegramAdapterConfig that lets callers
choose between "Markdown" (default, backward compatible), "MarkdownV2",
"HTML", or "none" (omit parse_mode entirely as a safety valve).

The converter is unchanged; this PR only exposes a knob so callers whose
upstream renderer produces MarkdownV2/HTML/plain-text can tell the adapter
not to ask Telegram to parse legacy Markdown entities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram adapter: parse_mode not set for markdown messages

2 participants