Skip to content

codestorm-official/python-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Telegram Bot with python-telegram-bot

Deploy on Railway

A starter Telegram bot project built with python-telegram-bot, environment-based configuration, Docker support, and Railway deployment setup.

Telegram Bot Demo

Features

  • Persistent chat menu buttons after /start
  • /start, /help, /about, and /ping commands
  • Echo replies for normal text messages
  • Fallback handler for unknown commands
  • Error logging
  • Bot token loaded from a local .env file or Railway variables
  • Ready to run with Docker and Railway

Chat Menu Buttons

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.

Bot Commands

Command Description
/start Show the welcome message
/help Show available commands
/about Show short bot information
/ping Check whether the bot is running

Project Structure

.
β”œβ”€β”€ bot/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ handlers.py
β”‚   └── main.py
β”œβ”€β”€ .env
β”œβ”€β”€ .env.example
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ .gitignore
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ LICENSE
β”œβ”€β”€ railway.json
β”œβ”€β”€ README.md
└── requirements.txt

Set Up the Bot Token

  1. Create a bot with Telegram @BotFather.
  2. Copy the bot token.
  3. Add the token to .env:

Environment Variables

Name Required Default Description
BOT_TOKEN Yes - Bot token from @BotFather
LOG_LEVEL No INFO Logging level, such as DEBUG, INFO, or ERROR

Install and Run Locally

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.main

For Windows PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m bot.main

Run with Docker

docker build -t telegram-bot .
docker run --env-file .env telegram-bot

License

This project is licensed under the MIT License. See LICENSE.

About

Just 1-click setup. Telegram bot with commands, echo & menu buttons πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Contributors