Setup & Deployment
Deploying Telegram Uploader Bot (Cloudflare Workers) requires a bot token from @BotFather, a Cloudflare account with Workers and D1 enabled, and either GitHub Actions CI (recommended) or local wrangler tooling.
1. @BotFather & Optional Channels
Section titled “1. @BotFather & Optional Channels”Configure your bot in @BotFather with standard Bot API settings:
- Create Bot & Copy Token: Run
/newbotand record the standard HTTP Bot API token (BOT_TOKEN). - Disable Group Access: Run
/setjoingroupsand select Disable so the bot operates strictly in private chats. - Disable Inline Mode: Run
/setinlineand select Turn off. - Optional Supporting Channels:
- Private Storage Channel (
STORAGE_CHANNEL_ID): Add the bot as Administrator (can_post_messages) to mirror uploads and unlock 1-subrequestcopyMessages()bulk delivery. - Log Channel (
LOG_CHANNEL_ID): Private channel (-100...) with the bot as Admin for alerts and JSON config backups (or route logs toownerDM). - Force-Join Channels: Add the bot as Admin to up to
8public or private channels required before downloads.
- Private Storage Channel (
2. Cloudflare Account, API Token & WAF Recommendation
Section titled “2. Cloudflare Account, API Token & WAF Recommendation”- Copy your 32-character Account ID (
CLOUDFLARE_ACCOUNT_ID) from the Cloudflare Dashboard. - Create an API Token (
CLOUDFLARE_API_TOKEN) from the Edit Cloudflare Workers template containing these permissions:Workers Scripts:WriteD1:WriteAccount Settings:ReadWorkers Routes:WriteDNS:Write
3. Secrets & Variables Reference
Section titled “3. Secrets & Variables Reference”| Name | Scope | Requirement | Description |
|---|---|---|---|
CLOUDFLARE_API_TOKEN |
GitHub Actions CI | Required | Cloudflare API token with Workers & D1 write access |
CLOUDFLARE_ACCOUNT_ID |
GitHub Actions CI | Required | 32-character Cloudflare Account ID |
BOT_TOKEN |
Worker Secret | Required | Standard Bot API HTTP token from @BotFather |
OWNER_ID |
Worker Secret | Required | Numeric Telegram user ID (1–15 digits) of the root Owner |
WEBHOOK_PATH |
Worker Secret | Required | Secret webhook route segment (matched on POST /<WEBHOOK_PATH>) |
WEBHOOK_SECRET |
Worker Secret | Required | Secret token header (X-Telegram-Bot-Api-Secret-Token, minimum 16 chars) |
BOT_USERNAME |
Worker Secret / Var | Recommended | Bot username without @ — skips cold-start getMe API call |
BOT_FIRST_NAME |
Worker Var | Optional | Display name fallback (defaults to "File Store Bot") |
STORAGE_CHANNEL_ID |
Worker Secret / Var | Optional | Private channel ID (-100...) for mirroring and bulk copy |
LOG_CHANNEL_ID |
Worker Secret / Var | Optional | Private log channel ID (-100...) for operational alerts and backups |
ENABLE_QUOTA_CACHE |
Worker Var | Optional | Set to "false" to disable the 5-minute in-memory quota cache |
4. Deployment Methods
Section titled “4. Deployment Methods”Option 1 — GitHub Actions CI (Recommended)
Section titled “Option 1 — GitHub Actions CI (Recommended)”The repository ships .github/workflows/deploy.yml, triggered automatically on push to main (ignoring docs/** and README*.md), on release (published), or manually via workflow_dispatch. It runs on ubuntu-latest with Node.js 24 and executes:
npm install --legacy-peer-depsnpx tsc --noEmit(strict TypeScript typecheck)node scripts/verify.mjs(runs the 8-check localization, HTML, and 64-byte callback suite)- Validate required CI and Worker secrets upfront
- Auto-provision the D1 database
filestore-dbin regionweurif absent - Apply schema & compatibility updates:
(followed by idempotent compatibility
Terminal window npx wrangler d1 execute filestore-db --remote --file=./schema.sql -yALTER TABLEstatements) - Seed
OWNER_IDdirectly into the D1adminstable - Deploy the Worker (
npx wrangler deploy) and sync Worker secrets (npx wrangler secret bulk)
Option 2 — Local wrangler Setup & Webhook Registration
Section titled “Option 2 — Local wrangler Setup & Webhook Registration”Provision D1, apply schema.sql, seed your Owner record, upload Worker secrets, and deploy locally:
npm install --legacy-peer-depsnpx wrangler d1 create filestore-db --location=weur# Copy the returned database_id into wrangler.toml before migrating:npx wrangler d1 execute filestore-db --remote --file=./schema.sql -ynpx wrangler d1 execute filestore-db --remote --command "INSERT OR IGNORE INTO admins (user_id, role, added_by) VALUES (<OWNER_ID>, 'owner', <OWNER_ID>);"npx wrangler secret put BOT_TOKENnpx wrangler secret put OWNER_IDnpx wrangler secret put WEBHOOK_PATHnpx wrangler secret put WEBHOOK_SECRETnpx wrangler deployWebhook Registration (scripts/webhook.mjs or Bot API)
Section titled “Webhook Registration (scripts/webhook.mjs or Bot API)”Manage the Telegram webhook using the built-in helper script (info, set, drop, or delete):
node scripts/webhook.mjs setnode scripts/webhook.mjs infoOr invoke Telegram’s setWebhook directly (max_connections=8, allowed_updates=["message","callback_query"], drop_pending_updates=true, secret_token=<WEBHOOK_SECRET>) in your shell:
-
Bash / macOS / Linux:
Terminal window curl -sS -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" \-H "Content-Type: application/json" \-d '{"url":"https://<WORKER_HOST>/<WEBHOOK_PATH>","secret_token":"<WEBHOOK_SECRET>","max_connections":8,"allowed_updates":["message","callback_query"],"drop_pending_updates":true}' -
Windows CMD:
Terminal window curl -sS -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d "{\"url\":\"https://<WORKER_HOST>/<WEBHOOK_PATH>\",\"secret_token\":\"<WEBHOOK_SECRET>\",\"max_connections\":8,\"allowed_updates\":[\"message\",\"callback_query\"],\"drop_pending_updates\":true}" -
Windows PowerShell:
Terminal window curl.exe -sS -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{\"url\":\"https://<WORKER_HOST>/<WEBHOOK_PATH>\",\"secret_token\":\"<WEBHOOK_SECRET>\",\"max_connections\":8,\"allowed_updates\":[\"message\",\"callback_query\"],\"drop_pending_updates\":true}'
Next Steps
Section titled “Next Steps”- Uploads, Delivery & Protection — Explore 1-subrequest bulk delivery, SHA-256 passcodes, and cron sweeps.
- Roles, Security & Operations — Review the 5-level RBAC matrix, rate limits, and
/restoreJSON backups. - Architecture, D1 Schema & Cron — Inspect the D1 schema, SQL triggers, and cron schedule.