Repository navigation
Set up Telegram from a bot token posted in the support chat - #1583
Merged
Merged
Conversation
Customers paste their Telegram bot token in the support chat instead of the setup page. On Cloud, the Libredesk message.created webhook now installs the Telegram Bot connector for them when the sender is the verified widget identity of a single-workspace editor or admin with a verified email, the workspace has no Telegram connector yet and Telegram's getMe accepts the token. Every install is a security event and is emailed to the user and the workspace admins. Existing connectors are never changed.
GitHub secret scanning flagged the literal test token (alert #5). It was never a real bot token.
helpcodeai
enabled auto-merge (squash)
November 8, 2026 17:40
CodeQL flagged /<[^>]*>/ as polynomial on input with many '<'. The token pattern works on Libredesk's HTML content as is.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Customers keep pasting their Telegram bot token into the support chat instead of the connector setup page, and then wait for us to install it by hand. This lets the Cloud backend do it from the chat, without a click, under strict identity rules.
Who is acting comes only from the verified widget identity, never from the message: Libredesk resolves the contact from the HS256 JWT our backend signs (
external_user_id = <host>:<userId>, secret only on Cloud), and the message must come from that contact. Everything else is re-checked in our database at install time.Changes
ee/support/support-telegram-setup.service.ts(new): onmessage.created, finds exactly one Telegram bot token in an incoming, non-private contact message and installstelegram-botwhen all of these hold:contact,external_user_idprefixed with this instance's host;getMeaccepts the token (otherwise the catalog's verify hint);LicenseGuardService); at most 3 such installs per workspace a day, one per conversation (tagtelegram-auto-setup).Then:
importAdapter+attachToDefaultServeras the dashboard does, security eventCONNECTOR_INSTALLED_VIA_SUPPORT_CHAT, product eventsetup_completed(via: support_chat), a reply in the chat, and an email to the user and every workspace admin.support.controller.ts: routesmessage.createdto it (the triage still handlesconversation.created).libredesk.client.ts:conversation()andreply().AdaptersModuleexportsAdaptersService; new security event name;connectorAddedFromSupportEmailtemplate +EmailService.sendConnectorAddedFromSupportEmail.Deployment modes: Cloud only in practice. The handler runs where
LIBREDESK_*is set (only Cloud). Dedicated instances and self-hosted installations do not load the triage webhook; self-hosted does not load the support module at all.The token is never logged, never echoed in the chat reply and not stored in the security event.
Type
Testing
support-telegram-setup.service.spec.ts: happy path, ignored senders/identities, unverified, several workspaces, viewer, existing connector, invalid token, plan limit, dedupe and daily limit)Commands, in
packages/backendafternpm ciandnpx prisma generate:npx jest src/ee/support src/settings/email src/adapters/adapters.controller --maxWorkers=4→ 8 suites, 1012 tests passednpx tsc --noEmit -p tsconfig.json→ no errorsnpm run lint→ 0 errors (11 existing warnings, none in changed files)npm test -- --maxWorkers=4→ 1044 suites passed;src/auth/jwt-or-management-key.guard.spec.tsfails with 13 tests, and fails the same way on cleanmain(baseline, not from this change)Checked against the live desk (read-only): conversation detail carries
inbox_channel: livechat,contact.id,contact.type: contact,contact.external_user_id = cloud.anythingmcp.com:<id>; incoming contact messages carrysender_id = contact.id.After deploy: add
message.createdto Libredesk webhook 1 (nowconversation.createdonly) and tell the desk's AI assistant not to ask for a revoke of a Telegram bot token.Checklist
npm test): see the baseline failure above