Setup & Deployment
Deploying Telegram Widget Bot (AZiPA/telegram-widget-bot) requires a bot configured in @BotFather with Telegram Serverless and Inline Mode enabled, plus either GitHub Actions CI (recommended) or the local @tgcloud/cli tool. The bot’s in-Telegram interface runs in English (en-US) only.
1. @BotFather Requirements
Section titled “1. @BotFather Requirements”Open @BotFather in Telegram and apply only the required settings for your bot:
- Create or Select Your Bot: Run
/newbot(or pick an existing bot) in@BotFather. - Enable Serverless & Copy CLI Access Token: Open
@BotFather → Your Bot → Serverless, activate Telegram Serverless, then navigate toServerless → CLI Access → Access tokenand copy the credential formatted asapp<id>:<secret>. - Enable Inline Mode: Run
/setinlinein@BotFatherand choose your bot sohandlers/inline_query.jsreceives inline@bot [query]searches. - Skip Unneeded Features: No Mini App URL, Group Mode, Threaded Mode, or Business Mode configuration is required under the default private-chat setup.
2. Choose a Deployment Method
Section titled “2. Choose a Deployment Method”Option 1 — Zero-Touch GitHub Actions CI (Recommended)
Section titled “Option 1 — Zero-Touch GitHub Actions CI (Recommended)”The repository ships with .github/workflows/deploy.yml, triggered automatically on push or manually via workflow_dispatch (with no workflow inputs). Jobs run on ubuntu-latest under Node.js 26 (actions/checkout@v7 and actions/setup-node@v7), concurrency group tgcloud-deploy (cancel-in-progress: false), and permissions: contents: read.
Add one single Repository Secret under Settings → Secrets and variables → Actions:
| Secret | Requirement | Format & Purpose |
|---|---|---|
TGCLOUD_TOKEN |
Required (Only Secret) | Telegram Serverless CLI Access Token formatted as app<id>:<secret> |
Zero other secrets are needed. Every CI run executes this exact 9-step sequence:
- Checkout Repository: Runs
actions/checkout@v7. - Verify Secret: Confirms
TGCLOUD_TOKENis non-empty before proceeding. - Setup Node.js
26: Provisions Node.js26viaactions/setup-node@v7. - Install Dependencies: Installs
@tgcloud/cliusingnpm install --no-audit --no-fund. - Validate Widgets: Runs
node scripts/validate-widgets.jsto enforce Profile 1 and<= 4,096B zlib-9 compressed size limits across every widget definition. - Check App Status: Runs
npx tgcloud statusto verify connectivity and current serverless state. - Push Runtime Bundle: Uploads the pure JavaScript bundle via
npx tgcloud push --force. - Apply Safe Migrations: Applies additive SQLite changes via
npx tgcloud migrate --safe. - Sync Webhook Updates: Reconciles Telegram
allowed_updatesvianpx tgcloud webhook sync.
Option 2 — Local @tgcloud/cli Workflow
Section titled “Option 2 — Local @tgcloud/cli Workflow”Run these commands from the repository root to validate widget budgets locally, authenticate, deploy code, apply safe migrations, and sync webhook update types:
npm installnpm run validate # Runs node scripts/validate-widgets.jsnpx tgcloud loginnpm run deploy # Runs node scripts/validate-widgets.js && tgcloud pushnpx tgcloud statusnpx tgcloud migrate --safenpx tgcloud webhook syncEnvironment Token & npx tgcloud run Across Shells
Section titled “Environment Token & npx tgcloud run Across Shells”When setting TGCLOUD_TOKEN manually or invoking a handler/endpoint via npx tgcloud run, use quoting rules matching your shell. In particular, Windows CMD requires outer double quotes " and escaped inner \" because CMD does not strip single quotes ':
-
Bash / macOS / Linux:
Terminal window export TGCLOUD_TOKEN="app12345:your_secret"npx tgcloud run endpoints/listWidgets '{}' --ctx '{"initData":{"user":{"id":123456789}}}' -
Windows PowerShell:
Terminal window $env:TGCLOUD_TOKEN = "app12345:your_secret"npx tgcloud run endpoints/listWidgets '{}' --ctx '{\"initData\":{\"user\":{\"id\":123456789}}}' -
Windows CMD:
Terminal window set "TGCLOUD_TOKEN=app12345:your_secret"npx tgcloud run endpoints/listWidgets "{}" --ctx "{\"initData\":{\"user\":{\"id\":123456789}}}"
Next Steps
Section titled “Next Steps”- Widgets, Commands & Uploads — Try Stopwatch, Poll, Tap Duel, inline search, and live
.htmlwidget uploads. - Widget Engine & Authoring — Author new Profile 1 widgets and run automated
validate-widgets.jschecks. - Configuration, Schema & API — Tune
WIDGET_CONFIGflags, inspect SQLite tables, and call Mini App endpoints.