Cross references:
- Extension README (Markdown):
../../README.md - Bot docs bridge page (Markdown):
../../docs/telegram-bot.md - Bot docs page (GitHub Pages): https://apartsinprojects.github.io/Web2Comics/HTML/telegram-bot.html
Scope note:
- This runbook documents deployment and operational checks only.
- Admin-only bot commands are intentionally excluded from user-facing docs.
- Verify onboarding/info commands:
/start,/welcome,/help,/about,/version,/user,/config,/explain,/debug - Verify generation commands:
- text, link, PDF, image, or voice/audio input
/invent <story>/random/peek,/peek<n>
- Verify configuration commands:
/vendors,/vendor,/text_vendor,/image_vendor,/models,/test/panels,/objective,/objectives+ objective shortcuts (/summary,/fun,/learn,/news,/timeline,/facts,/compare,/5yold,/eli5,/study,/meeting,/howto,/debate)/style+ style shortcuts (/classic,/noir,/manga,/superhero,/watercolor,/newspaper,/cinematic,/anime,/cyberpunk,/pixel-art,/retro-pop,/minimalist,/storybook,/ink-wash,/line-art,/clay-3d)/new_style,/language,/mode,/consistency,/detail,/crazyness,/concurrency,/retries/prompts,/set_prompt,/list_options,/options/keys,/setkey,/unsetkey,/reset_config,/restart
This runbook covers deployment of the Telegram webhook bot in telegram/src/webhook-bot.js with persistent storage in Cloudflare R2.
- Node 20+
- Repo checked out and dependencies installed (
npm ci) - Telegram bot token from BotFather
- Render API key + owner id
- Cloudflare R2 bucket and S3 credentials
- At least one text/image provider key (Gemini recommended)
Set these in GitHub Secrets (recommended) or local env for manual deployment.
- Core:
RENDER_API_KEYRENDER_OWNER_IDTELEGRAM_BOT_TOKENTELEGRAM_WEBHOOK_SECRET
- Telegram routing:
TELEGRAM_NOTIFY_CHAT_IDTELEGRAM_TEST_CHAT_IDCOMICBOT_ALLOWED_CHAT_IDS
- Providers:
GEMINI_API_KEYOPENAI_API_KEYOPENROUTER_API_KEYHUGGINGFACE_INFERENCE_API_TOKENCLOUDFLARE_ACCOUNT_IDCLOUDFLARE_WORKERS_AI_TOKEN(Cloudflare Workers AI provider token)CLOUDFLARE_ACCOUNT_API_TOKEN(Cloudflare account token for R2 bucket API/provisioning)CLOUDFLARE_API_TOKEN(compatibility alias; set to the same value asCLOUDFLARE_WORKERS_AI_TOKEN)- Do not use legacy
--cloudflare-api-tokendeploy argument (deprecated and rejected)
- Storage/database:
R2_S3_ENDPOINTR2_BUCKETR2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEY
Validate mapping and required env values before deploy:
npm run secrets:validate:deploy
npm run secrets:validate:deploy:ciAudit GitHub repo plus environment secrets before dispatching the workflow:
npm run secrets:validate:deploy:github:staging
npm run secrets:validate:deploy:github:productionPredeploy also enforces strict Cloudflare token roles:
CLOUDFLARE_WORKERS_AI_TOKEN= Workers AI provider tokenCLOUDFLARE_ACCOUNT_API_TOKEN= Cloudflare account API token- If
CLOUDFLARE_API_TOKENis set, it must matchCLOUDFLARE_WORKERS_AI_TOKEN
CI workflows also enforce these checks:
.github/workflows/bot-deploy.yml.github/workflows/bot-tests.yml
Primary path:
npm run bot:deploy:auto -- --target render --env staging --branch stage1 --env-onlyUseful variants:
npm run bot:deploy:auto -- --target render --env staging --branch stage1 --env-only --with-render-smoke
npm run bot:deploy:auto -- --target cloudflare --env-only --with-cloudflare-smoke
npm run bot:deploy:auto -- --target both --env staging --branch stage1 --env-only --with-render-smoke --with-cloudflare-smokeBy default, bot:deploy:auto now runs a post-deploy sanity E2E check for Render (telegram/scripts/postdeploy-sanity.js).
Skip it only when needed:
npm run bot:deploy:auto -- --target render --env staging --branch stage1 --env-only --skip-sanity- Creates/reuses Render service
- Creates/reuses R2 bucket (if API token/account provided)
- Verifies R2 read/write/delete
- Syncs service environment variables
- Deploys service and waits for live status
- Registers Telegram webhook with
drop_pending_updates=true
- The deploy sanity probe now sends a plain-text marker message through the webhook path.
- It intentionally avoids unknown slash commands so deployment checks do not create
Unrecognized command.noise in the user-facing Telegram chat.
GET /healthzreturns 200- Send
/helpand/aboutin Telegram - Send short text and verify:
- prompt expansion notice for very short prompts
/crazynessvalue affects story invention intensity- panel delivery starts as soon as panels are generated
- captions use
X(Y)prefix format - panel image watermark appears bottom-right (
made with Web2Comics) - messages/photos are forwardable (not content-protected)
- Send URL and verify URL rendering flow works
- bot prints exact parsed URL before extraction (
Detected link, parsing page: <url>)
- bot prints exact parsed URL before extraction (
- Verify handled recovery noise is not shown to the user
- successful provider/extractor fallbacks should stay in internal logs
- terminal failures may still notify the user, but should use clean user-facing wording instead of raw provider credential text
- Sanity script (automatic in deploy wrapper):
- health endpoint check
- webhook plain-text marker trigger
- R2 request-log marker detection
- R2 image growth (live provider path)
- Telegram
sendMessageAPI probe
- Re-run deploy with previous branch/commit
- Keep webhook secret stable unless rotation is required
- If rotated, redeploy and re-register webhook immediately
- Production deploys must use
--env production --branch main