Skip to content

feat(telegram): expose parseMode config option#366

Closed
Koshkoshinsk wants to merge 1 commit intovercel:mainfrom
Koshkoshinsk:telegram-parse-mode-config
Closed

feat(telegram): expose parseMode config option#366
Koshkoshinsk wants to merge 1 commit intovercel:mainfrom
Koshkoshinsk:telegram-parse-mode-config

Conversation

@Koshkoshinsk
Copy link
Copy Markdown

Problem

Since #245, the Telegram adapter hardcodes parse_mode: "Markdown" whenever the caller passes { markdown: ... }. Telegram considers legacy Markdown a deprecated mode (see Bot API formatting options) 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 permanently.

For example, an agent reply containing routine markdown like:

- **Trigger required?** (does every message need the trigger…)
- **Folder** name (e.g. `telegram_family-chat`)

is rejected by Telegram, and there is currently no way for the caller to pick a different parse mode or disable parsing entirely.

Change

Adds an optional parseMode field to TelegramAdapterConfig:

parseMode?: "Markdown" | "MarkdownV2" | "HTML" | "none";

The markdown converter is unchanged; this PR only exposes a knob. Callers whose upstream renderer produces MarkdownV2/HTML/plain-text can now tell the adapter not to ask Telegram to parse legacy Markdown entities.

Tests

  • New: parseMode: "MarkdownV2" and "HTML" round-trip into the request body.
  • New: parseMode: "none" omits parse_mode entirely.
  • New: invalid parseMode value throws ValidationError from the constructor.
  • Existing parse_mode tests continue to pass with the unchanged default.

pnpm turbo build --filter @chat-adapter/telegram and pnpm vitest run (105 tests) both clean.

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.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 12, 2026

@Koshkoshinsk is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@Koshkoshinsk
Copy link
Copy Markdown
Author

Closing — going to handle this on our caller side instead, no upstream change needed for now.

@Koshkoshinsk Koshkoshinsk deleted the telegram-parse-mode-config branch April 12, 2026 08:26
@Koshkoshinsk
Copy link
Copy Markdown
Author

Reopening — apologies for the churn, the close was unintended on my end. Branch restored.

Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

TelegramParseMode type is not re-exported from the package's public API, making it impossible for consumers to import.

Fix on Vercel

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.

1 participant