A monorepo containing a Telegram Bot and a Svelte web application, both running on Cloudflare Workers and Pages.
This is a monorepo containing:
bot: The main Telegram Bot built with grammY — codebam/telegram-bot (submodule)webapp: A Svelte 5 web application for interacting with the bot — codebam/telegram-webapp (submodule)packages/shared: Types and helpers shared by both
-
Clone the repository with submodules:
git clone --recursive https://github.com/codebam/cf-workers-telegram-bot.git cd cf-workers-telegram-bot -
Install dependencies:
npm install
-
Set up Git hooks (runs the full build on every commit):
./setup_hooks.sh
-
Authenticate wrangler:
npx wrangler login
-
Configure: edit
bot/wrangler.tomlwith your worker name and bindings. Note that[env.dev]and[env.production]must point at different KV namespaces and Vectorize indexes. -
Set secrets: get a token from @BotFather, then:
cd bot npx wrangler secret put SECRET_TELEGRAM_API_TOKEN --env production npx wrangler secret put SECRET_TELEGRAM_WEBHOOK --env production # webhook shared secret npx wrangler secret put SECRET_ADMIN_TOKEN --env production # guards GET /?command=set npx wrangler secret put TAVILY_API_KEY --env production # optional, web search
Repeat with
--env devfor the development worker. -
Deploy:
make deploy-bot # or: cd bot && npx wrangler deploy --env production -
Register the webhook (once per deploy target):
curl "https://<your-worker-host>/?command=set&token=<SECRET_ADMIN_TOKEN>"
For more on deploying grammY bots, see the grammY deployment documentation.
The web app is a SvelteKit project deployed to Cloudflare Pages.
make deploy-webapp
# or: cd webapp && npm run build && npx wrangler pages deploy .svelte-kit/cloudflaremake deploymake build # Build all projects
make clean # Clean build artifacts
npm run start --workspace bot # local worker via wrangler dev
npm run dev --workspace webapp # local webapp via viteCI runs on GitHub Actions (.github/workflows/deploy.yml):
| Trigger | Action |
|---|---|
push to master |
deploy bot to the dev environment |
tag bot-v* |
deploy bot to production |
tag webapp-v* |
deploy webapp to Cloudflare Pages |
Cut releases with the release script. It fetches tags first (the remote is authoritative for numbering), refuses to run on dirty worktrees or stale branches, runs the same checks as the deploy workflow, creates the next patch tag per component and pushes submodule branches before the superproject and tags, because the workflow checks submodules out at the tagged commit.
./scripts/release.sh both # bot + webapp, GPG-signed tags
./scripts/release.sh bot # bot only
./scripts/release.sh bot -m "fix reason" # custom tag message
./scripts/release.sh both -d # dry run, prints the plan onlyPass --no-sign for annotated (unsigned) tags, --no-push to stop after tag
creation, or --skip-checks if you already ran the checks.
Required repository secrets:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDSECRET_TELEGRAM_API_TOKEN,SECRET_TELEGRAM_API_TOKEN_DEVTAVILY_API_KEY
Apache-2.0

