Beginner-Friendly Telegram Bot Boilerplate: Easy Setup and Modular Design
Discover a simple and modular Telegram bot boilerplate built with Pyrogram. Perfect for beginners, this guide walks you through the setup, structure, and features to get your bot up and running in minutes.


Building Telegram Bots Made Simple: A Beginner-Friendly Boilerplate
If you've ever wanted to create a Telegram bot but felt overwhelmed by the complexity, I've got you covered! Let me introduce you to a simple, beginner-friendly boilerplate that makes starting your Telegram bot project a breeze.
Hereโs everything you need to know to get started with this boilerplate, step by step.
๐ ๏ธ What Is This Boilerplate?
This boilerplate is a ready-to-use framework for creating Telegram bots using Pyrogram, a powerful Python library for interacting with the Telegram Bot API.
Itโs designed to:
- Save time by setting up a basic structure for your project.
- Keep your code clean and organized using a modular approach.
- Help you focus on building cool features instead of worrying about setup.
You can check it out here: GitHub Repository
๐ Why Use This Boilerplate?
- Simplicity: You donโt need to start from scratchโjust plug in your details and go.
- Modular Design: Commands and features are organized into separate files, making it easy to add or modify functionality.
- Beginner-Friendly: Even if youโre new to Python or Pyrogram, the structure makes it easy to understand.
- Quick Setup: With just a few commands, your bot will be up and running in minutes.
๐ Project Structure
Hereโs a quick look at how everything is organized:
tgbot-boilerplate/
โโโ plugins/ # All your bot commands and features โ
โโโ callback.py # Example for handling button clicks (callbacks)
โ โโโ commands.py # Example for basic commands like /start
โโโ bot.py # Main file that runs the bot
โโโ db.py # Placeholder for database connection (if needed)
โโโ vars.py # Handles environment variables like API keys
โโโ requirements.txt # Python dependencies
โโโ .env # Your API keys and bot credentials (ignored by Git)
๐ Step-by-Step Guide to Get Started
1. Clone the Repository
First, grab the boilerplate from GitHub and navigate into the project directory:
git clone https://github.com/biisal/tgbot-boilerplate.git
cd tgbot-boilerplate
2. Install Dependencies
Make sure you have Python 3.9 or higher installed. Install the required Python libraries using:
pip install -r requirements.txt
3. Set Up Your Bot Credentials
- Go to Telegram BotFather and create a bot.
- Note down the API ID, API Hash, and Bot Token provided by BotFather.
Next, create a .env
file in the project root and add the following:
API_ID=your_api_id
API_HASH=your_api_hash
BOT_TOKEN=your_bot_token
ADMIN=your_telegram_user_id
4. Run the Bot
Now, itโs time to launch your bot! Just run:
python3 bot.py
๐ Thatโs it! Your bot is now live and ready to respond.
โจ Cool Features in the Boilerplate
Example Command: /start
When users type /start
, they get a friendly message along with an inline keyboard:
@Client.on_message(filters.command("start") & filters.incoming)
async def start(client: Client, message: Message):
await message.reply_text(
f"**Hello {message.from_user.first_name}!**\nThis boilerplate is ready to go.",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Help", url="https://t.me/devdoptpy"),
InlineKeyboardButton("Callback ping", callback_data=f"ping#{message.from_user.id}")
]
]
)
)
Example Callback
The boilerplate also includes an example of handling button callbacks using the callback.py
file.
๐ Why This Boilerplate Is Perfect for Beginners
- No Messy Setup: The project is already organizedโyou can just dive into writing commands.
- Customizable: Add features like databases, APIs, or advanced commands without breaking a sweat.
- Pyrogram Power: Pyrogram simplifies interactions with Telegram, giving you more time to focus on your botโs logic.
๐ก Tips for Expanding Your Bot
- Add New Commands: Create new Python files in the
plugins/
folder for different commands. - Integrate Databases: Use
db.py
to connect your bot to a database like MongoDB or PostgreSQL. - Explore Pyrogram Docs: Learn about the full range of features Pyrogram offers here.
๐ค Contribute and Customize
This boilerplate is open-source, and contributions are welcome! If you have ideas or improvements, feel free to fork the repo and create a pull request.
๐ Ready to Build Your Own Telegram Bot?
Start your journey with this boilerplate:
๐ GitHub Repository
Letโs build something awesome together! ๐
About the Author

Avisek Ray
I am a skilled full-stack developer with expertise in Python (Django, FastAPI) and JavaScript (Next.js, React). With over a year of experience, Iโve delivered scalable web applications, including a news website and an AI-powered project planner. I focus on creating secure, high-performance solutions while continually expanding my skills in SQLAlchemy, Docker, and advanced Python practices. Driven by curiosity and a passion for problem-solving, I aim to build impactful, innovative applications