Skip to content

feat(telegram): add Business mode support - #888

Merged
bensabic merged 5 commits into
vercel:mainfrom
psychomet:feat/telegram-business-mode
Sep 4, 2026
Merged

feat(telegram): add Business mode support#888
bensabic merged 5 commits into
vercel:mainfrom
psychomet:feat/telegram-business-mode

Conversation

@psychomet

Copy link
Copy Markdown
Contributor

Summary

  • Adds Telegram Business mode support to @chat-adapter/telegram
  • Handles business_connection, business_message, and edited_business_message updates
  • Passes business_connection_id on outbound sends, edits, typing, and file uploads
  • Opt-in via businessMode: true (default off, backward compatible)

Closes #887

Test plan

  • Unit tests pass (pnpm --filter @chat-adapter/telegram test — business mode suite)
  • Manually tested with a Business-connected bot (business_message in → reply out)
  • Existing DM/group behavior unchanged with businessMode: false

@psychomet
psychomet requested a review from a team as a code owner September 2, 2026 05:00
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

In processUpdate, business message updates are excluded from userId resolution, so when allowedUserIds is configured every business_message/edited_business_message update resolves userId to undefined and is dropped by the allowlist early-return.

Fix on Vercel

Comment thread packages/adapter-telegram/src/index.ts Outdated
psychometdev and others added 5 commits September 4, 2026 13:49
Handle business_connection, business_message, and pass
business_connection_id on outbound API calls.

Closes vercel#887

Signed-off-by: Psychomet <psychomet.dev@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve customer userId for allowedUserIds on business_message updates.
Omit business_connection_id from deleteMessage and setMessageReaction.

Signed-off-by: Psychomet <psychomet.dev@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
… to end

Business threads are now their own channel, so channel posts keep
business_connection_id and locks and history stay separate from the
customer's direct bot chat. Callback queries, slash commands, and media
groups in business chats resolve to the business thread.

Deletes go through deleteBusinessMessages. Reactions throw a
NotImplementedError since the Bot API has no business variant.
fetchThread carries the connection id and falls back to cached chat
details when getChat cannot resolve the customer.

Connection state moves from a per-instance Map into the state adapter
with a TTL, and is recorded before the allowedUserIds gate so rights
changes always land. Outgoing echoes carrying sender_business_bot are
skipped and attributed to the bot. Polling always sends an explicit
allowed_updates list in Business mode.
Cover channel separation, slash commands, deletes via
deleteBusinessMessages, the reaction limitation, polling
allowed_updates, and the telegram:biz sharding caveat.
Split the business fixture into separate connection, customer message,
bot-sent echo, and edited message updates. Document the telegram:biz
thread format and business update routing in AGENTS.md.
@bensabic
bensabic force-pushed the feat/telegram-business-mode branch from 851a11d to 4ba410d Compare September 4, 2026 03:51
@bensabic
bensabic enabled auto-merge (squash) September 4, 2026 03:57
@bensabic
bensabic merged commit 043386b into vercel:main Sep 4, 2026
13 of 15 checks passed
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: support Business mode (business_message, business_connection)

3 participants