Template

Telegram bot (Python, aiogram 3)

Routers, typed handlers, polling or an aiohttp webhook server with secret-token verification and /healthz.

Download ZIP (6.6 KB)

SHA-256: 80501734225d251bbd9d965e4eba925f1606df9ff92a8bd6ba8e130d6e5945a9 (checksum file)

Stack: Python 3.10+, aiogram 3.x · License: MIT · Files: 12

What it includes

Routers, typed handlers, polling or an aiohttp webhook server with secret-token verification and /healthz.

File tree

telegram-aiogram/
├── bot/
│   ├── __init__.py
│   ├── logic.py
│   └── main.py
├── tests/
│   └── test_logic.py
├── .dockerignore
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── requirements-dev.txt
└── requirements.txt

Setup

unzip telegram-aiogram.zip && cd telegram-aiogram
python -m venv .venv && . .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env
set -a; . ./.env; set +a; python -m bot.main
pytest -q

Fill in .env with credentials from the platform's official developer console. Never commit it: the included .gitignore excludes it.

Step-by-step guide

  1. Download the ZIP above, check its SHA-256 and unzip it.
  2. Open @BotFather in Telegram, send /newbot and copy the token into BOT_TOKEN.
  3. Copy .env.example to .env (or .dev.vars for Workers) and paste the values. Never commit it.
  4. Install dependencies and run the tests: they pass without network access.
  5. Run it locally with the commands in the Setup section and send your bot a message.
  6. Push the folder to a private GitHub repository so a host can build it.

Deploy on Railway

  1. Press Deploy on Railway below and sign in (it opens a new Railway project).
  2. Choose Deploy from GitHub repo and pick your repository. Railway detects the included Dockerfile.
  3. Open Variables and add: BOT_TOKEN, MODE=webhook, WEBHOOK_URL=https://<your-domain>/telegram/webhook, WEBHOOK_SECRET, PORT=8080.
  4. In Settings → Networking generate a public domain so the platform can reach your webhook.
  5. Watch the deploy logs until the bot reports it is running, then test it. Set a usage limit in your Railway workspace settings.

Deploy on Railway

Affiliate link (referral code 8Mexkc): BotNetwork may earn a commission at no extra cost to you. The button opens Railway's new-project page; this template is not a published one-click Railway template, so you connect your own repository. Railway bills by usage: check its pricing page.

Next steps

Run with Docker

docker build -t telegram-aiogram .
docker run --rm --env-file .env telegram-aiogram

Official documentation

https://docs.aiogram.dev

All templates