Integrations
Telegram bot
/_authed/bot configures the customer-facing storefront bot (and an optional second support bot) that most Telegram users interact with instead of the web panel. It has seven tabs: Main bot, Support bot, Features, Admin controls, Content, Broadcast, Direct message.Data is fetched with api.bot.get() (→ BotSettings) and saved with api.bot.save(patch); api.bot.restart() restarts both bot processes ("Bot & panel restarting"). The top bar shows the auto-detected @username, a live status dot computed as data.running && data.enabled, the support bot handle if configured, any lastError banner, an "unsaved" badge when the form is dirty, and Restart / Save buttons.
Under the hood, the bot is a Python process (backend/agent/bot.py) that itself calls the same agent over HTTP as the panel (agent() helper hitting paths like /bot/...) — so bot actions and panel actions share one backend source of truth.
| Field | Meaning |
|---|---|
| Enabled | Switch that turns the whole customer-facing bot on/off. |
| Bot token | Obtained from @BotFather; pasted directly (token field, plaintext — unlike the masked support token). |
| Admin chat ID | Receives new-payment notifications. If empty, the first user to run /admin is auto-registered as the admin — the bootstrap mechanism for who holds bot-admin rights. |
| Log chat ID (optional) | Server activity forwarding target. The bot must be admin of that channel/group; paste its numeric chat id (negative for groups/channels, e.g. -1001234567890). |
| Force-join channel / Community group | @handles shown in the welcome message — implied required-to-join gates before using the bot. |
Fields
- Support bot token
- Separate BotFather token. Leaving it empty and saving disables the support bot (falls back to routing everything through the main bot). Once saved, shows
***masked; you must type a new token to replace it. - Support bot username
- Auto-detected on save; can be overridden for display.
- Mechanics
- Admin replies and support DMs route through this bot when configured; users tap a support link in the main bot to land here; if this bot is offline, messages fall back to the main bot automatically.
Reply mode (supportMode)
| Mode | Behavior |
|---|---|
| none | Bot stays silent; tickets only land in the admin chat and the web Support page (pure inbox). |
| human | Messages are silently forwarded; optional one-time manualReplyText first-message line, or fully silent. |
| bot | Bot immediately acknowledges with an ETA (botAckText, default text if blank, plus expectedReplyMinutes, default 15), then delivers the admin's real answer once typed in the Support page. |
A "Forward user messages to admin" toggle is also present, likely controlling whether raw user messages are copied into the admin/log chat regardless of reply mode.
BotFeaturesCard controls a matrix of enable/disable feature flags. In bot.py, the feat(u, name) helper reads a bot_features map where a missing key means the feature is enabled by default — so this tab is an opt-out surface for individual bot capabilities rather than an opt-in one.
AdminControlsCard lets the admin manage admin-side access beyond the single bootstrap adminChatId set in the Main bot tab — i.e. the list of chat ids/permissions that can use the in-Telegram admin screens described in §10.9 below.
| Field | Meaning |
|---|---|
| Welcome message (welcomeText) | Supports placeholders {name}, {username}, {brand}; blank uses the default greeting built by _default_welcome (an HTML greeting using BRAND_NAME). |
| Welcome image / GIF URL (welcomeMedia) | Sent above the welcome text on /start. |
| Payment instructions (paymentInstructions) | Shown when a user picks a plan — bank/crypto/QRIS details etc. |
| Payment QR image URL (paymentQrUrl) | QR code image shown alongside payment instructions. |
| Auto-delete sensitive messages (minutes) (autoDeleteMinutes) | Default 10 — configs, payment details, and receipts self-delete from the chat after this many minutes. |
BroadcastCard sends an announcement to all bot users — a general-purpose message blast, separate from the Gifts/Coupons broadcast mechanism used specifically for redeem/coupon codes (see the Gifts, codes, referrals page).
DirectMessageCard sends a one-off DM to a specific Telegram ID from this page — a convenience parallel to the DM action available on a user row in the Users page.
Registered top-level commands in backend/agent/bot.py (main bot):
| Command | What it does |
|---|---|
| /start | Routes to user home or admin home depending on is_admin(); also carries referral deep-link payloads (ref=<code>). |
| /me | Shortcut to "my accounts" list (user_accounts). |
| /admin | Opens the admin panel (admin_home); replies "Not authorized." if is_admin() is false. |
| /restore | Admin only — prompts for an autoscript-backup-*.tar.gz file to restore a system backup. |
| /cancel | Clears any pending multi-step input state (awaiting, adm_await, order_id, topup_pending_id). |
| /done | Finalizes a multi-step flow (not detailed further in the source excerpt). |
| /help | Lists /start, /me, and — if admin — /admin, /restore. |
| /redeem | Prompts for and consumes a redeem code. |
| /coupon | Prompts for and consumes a coupon code. |
On the separate support bot instance (when configured): /start, /cancel, /help are wired to the support conversation flow (support_cmd_start, support_cmd_cancel).
CallbackQueryHandler(on_button)— every inline-keyboard button tap.on_photo/on_document— payment proof uploads and backup restores.on_text— general text handler for multi-step prompts ("type amount", "type username", coupon/redeem code entry).ChatMemberHandler (on_my_chat_member)— detects when the bot is added/removed as admin of a chat, feeding the "chats where bot is admin" list used by Gifts/Redeem broadcasting._admin_block_gate— an earlyTypeHandlergate (group -10) that runs before everything else, enforcing the Users-page block list.
These mirror web-panel functionality directly inside Telegram, reachable by an admin via /admin:
| Screen | What it does |
|---|---|
| admin_home / admin_dash | Admin dashboard inside Telegram (stats, live connections). |
| admin_live | Live connections list. |
| admin_usage | Usage/traffic browser with time-range paging. |
| admin_users / admin_user_detail | Browse users, view activity feed, adjust points (admin_user_points), reset trial (admin_user_reset_trial), DM a user (admin_user_dm). |
| admin_accounts / admin_account_show / admin_extend / admin_go | Browse accounts, extend expiry by N days, and confirm-then-execute actions like delete/reset via admin_confirm. |
Same moderation, two surfaces
- 1In Telegram, message @BotFather, run
/newbot, follow the prompts to get a token like123456:ABC-DEF.... - 2In the panel, go to Bot → Main bot.
- 3Paste the token into Bot token.
- 4Toggle Enabled on.
- 5Click Save (top-right sticky bar) — this restarts/reconnects the bot process with the new token.
- 6In Telegram, message your new bot and send
/admin— since Admin chat ID is empty, you are auto-registered as the bot admin. Optionally copy your numeric chat id into Admin chat ID afterward to lock it in. - 7Optionally set Force-join channel / Community group handles.
- 8Go to the Content tab to customize welcome text/image and payment instructions/QR before going live.
- 9Optionally go to the Support bot tab, create a second BotFather bot, paste its token, save, and choose a Reply mode.
- 10Click Restart any time the bot seems stuck or after major settings changes.
- 11A user now runs
/start, browses Plans (see the Plans & pricing page), picks one, uploads a payment proof screenshot, and the order lands in Payments → Pending for you to approve — completing the first purchase.
