Skip to content

Setup & Deployment

Deploying Telegram Uploader Bot (Telegram Serverless) requires a bot configured in @BotFather with Telegram Serverless enabled, plus either GitHub Actions CI (recommended) or the local @tgcloud/cli tool.

Open @BotFather in Telegram and prepare your bot and optional supporting channels:

  1. Create Your Bot: Run /newbot in @BotFather and choose a display name and username.
  2. Enable Serverless: Open @BotFather → Your Bot → Serverless and activate Telegram Serverless hosting.
  3. Copy the CLI Access Token: Open Serverless → CLI Access → Access token and copy the credential formatted as `app<id>:<secret>`.
  4. Optional Supporting Channels:
    • Private Storage Channel: Create a private channel, add your bot as Administrator with can_post_messages: true, and verify that Content Protection (has_protected_content) is OFF. If content protection is enabled on the storage channel, mirroring and api.copyMessages() fallback will fail.
    • Log Channel: Create a private channel (-100...) with the bot as Admin to receive operational alerts, or route logs directly to the Owner’s private chat via /setlogchannel owner.
    • Force-Join Channels: Add the bot as Administrator to up to 8 public or private channels you plan to require before bundle downloads.
Section titled “Option 1 — GitHub Actions CI (Recommended)”

The repository includes .github/workflows/deploy.yml, triggered automatically on push or manually via workflow_dispatch with concurrency group tgcloud-deploy (cancel-in-progress: false). Jobs run on ubuntu-latest with Node.js 24 (actions/checkout@v7 with persist-credentials: false, actions/setup-node@v4).

Configure these Repository Secrets under Settings → Secrets and variables → Actions:

Secret Requirement Purpose
TGCLOUD_TOKEN Required Serverless CLI Access Token formatted as `app<id>:<secret>`
OWNER_ID Optional Numeric Telegram user ID for automated Zero-Touch owner seeding

Each CI workflow run executes this exact deployment sequence (where $CLI invokes @tgcloud/cli):

Terminal window
npm install --no-audit --no-fund
$CLI push --force
$CLI migrate --safe
$CLI webhook sync
# Executed automatically if the OWNER_ID secret is set:
$CLI run handlers/message "{\"owner_id\":$OWNER_ID}" --ctx "{\"ci_bootstrap\":true}"

Option 2 — Local CLI Deployment (@tgcloud/cli)

Section titled “Option 2 — Local CLI Deployment (@tgcloud/cli)”

Run the following sequence from the repository root to authenticate, deploy code, apply safe additive migrations, and synchronize the webhook:

Terminal window
npm install
npx @tgcloud/cli login
npx @tgcloud/cli push
npx @tgcloud/cli migrate --safe
npx @tgcloud/cli webhook sync

To seed ownership locally instead of relying on interactive Zero-State claiming, replace 123456789 with your numeric Telegram user ID and run the syntax matching your shell:

  • Bash / macOS / Linux:

    Terminal window
    npx @tgcloud/cli run handlers/message '{"owner_id":123456789}' --ctx '{"ci_bootstrap":true}'
  • Windows CMD:

    Terminal window
    npx @tgcloud/cli run handlers/message "{\"owner_id\":123456789}" --ctx "{\"ci_bootstrap\":true}"
  • Windows PowerShell:

    Terminal window
    npx @tgcloud/cli run handlers/message '{\"owner_id\":123456789}' --ctx '{\"ci_bootstrap\":true}'

Telegram Uploader Bot supports two distinct ownership initialization flows:

Path How It Works When to Use
Zero-Touch CI/CD Seeding (Recommended) Setting OWNER_ID in CI (or running --ctx '{"ci_bootstrap":true}' locally) idempotently seeds system_config.owner_id before any Telegram user messages the bot. Production and team deployments where ownership must be locked from second zero.
Zero-State Interactive Claim When deployed without OWNER_ID (system_config.owner_id = 0), the bot enters a fail-closed Zero-State (bot_uninitialized) and blocks public use until the first user sends /setbotowner in private chat to atomically claim ownership. Quick personal setups where CI secrets or local CLI run seeding were omitted.