Skip to content

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.

Open @BotFather in Telegram and apply only the required settings for your bot:

  1. Create or Select Your Bot: Run /newbot (or pick an existing bot) in @BotFather.
  2. Enable Serverless & Copy CLI Access Token: Open @BotFather → Your Bot → Serverless, activate Telegram Serverless, then navigate to Serverless → CLI Access → Access token and copy the credential formatted as app<id>:<secret>.
  3. Enable Inline Mode: Run /setinline in @BotFather and choose your bot so handlers/inline_query.js receives inline @bot [query] searches.
  4. Skip Unneeded Features: No Mini App URL, Group Mode, Threaded Mode, or Business Mode configuration is required under the default private-chat setup.
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:

  1. Checkout Repository: Runs actions/checkout@v7.
  2. Verify Secret: Confirms TGCLOUD_TOKEN is non-empty before proceeding.
  3. Setup Node.js 26: Provisions Node.js 26 via actions/setup-node@v7.
  4. Install Dependencies: Installs @tgcloud/cli using npm install --no-audit --no-fund.
  5. Validate Widgets: Runs node scripts/validate-widgets.js to enforce Profile 1 and <= 4,096 B zlib-9 compressed size limits across every widget definition.
  6. Check App Status: Runs npx tgcloud status to verify connectivity and current serverless state.
  7. Push Runtime Bundle: Uploads the pure JavaScript bundle via npx tgcloud push --force.
  8. Apply Safe Migrations: Applies additive SQLite changes via npx tgcloud migrate --safe.
  9. Sync Webhook Updates: Reconciles Telegram allowed_updates via npx tgcloud webhook sync.

Run these commands from the repository root to validate widget budgets locally, authenticate, deploy code, apply safe migrations, and sync webhook update types:

Terminal window
npm install
npm run validate # Runs node scripts/validate-widgets.js
npx tgcloud login
npm run deploy # Runs node scripts/validate-widgets.js && tgcloud push
npx tgcloud status
npx tgcloud migrate --safe
npx tgcloud webhook sync

Environment 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}}}"