A starter Telegram bot project built with python-telegram-bot, environment-based configuration, Docker support, and Railway deployment setup.
- Persistent chat menu buttons after
/start /start,/help,/about, and/pingcommands- Echo replies for normal text messages
- Fallback handler for unknown commands
- Error logging
- Bot token loaded from a local
.envfile or Railway variables - Ready to run with Docker and Railway
The bot shows a persistent reply keyboard after /start with these buttons:
| Button | Action |
|---|---|
Help |
Show available commands |
About |
Show short bot information |
Ping |
Check whether the bot is running |
Telegram bots cannot display custom buttons before a user starts or messages the bot. The keyboard appears after the bot replies, then stays available in supported Telegram clients.
| Command | Description |
|---|---|
/start |
Show the welcome message |
/help |
Show available commands |
/about |
Show short bot information |
/ping |
Check whether the bot is running |
.
βββ bot/
β βββ __init__.py
β βββ config.py
β βββ handlers.py
β βββ main.py
βββ .env
βββ .env.example
βββ .dockerignore
βββ .gitignore
βββ Dockerfile
βββ LICENSE
βββ railway.json
βββ README.md
βββ requirements.txt
- Create a bot with Telegram
@BotFather. - Copy the bot token.
- Add the token to
.env:
| Name | Required | Default | Description |
|---|---|---|---|
BOT_TOKEN |
Yes | - | Bot token from @BotFather |
LOG_LEVEL |
No | INFO |
Logging level, such as DEBUG, INFO, or ERROR |
Make sure Python 3.10 or newer is installed.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m bot.mainFor Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m bot.maindocker build -t telegram-bot .
docker run --env-file .env telegram-botThis project is licensed under the MIT License. See LICENSE.
