A beginner-friendly Telegram bot built with Python using python-telegram-bot. The bot responds to messages, handles commands, and can be easily extended.
- Responds to /start and /help commands
- Easy to extend with custom commands
- Beginner-friendly setup
- Python 3.9+
- python-telegram-bot
Follow these steps to set up the Telegram bot on your local machine:
- Clone the repository
Download the project to your computer using Git:
git clone https://github.com/YourUsername/telegram-chatbot.git
cd telegram-chatbot
- Install Python dependencies
Make sure you have Python 3.9+ installed. Then install the required packages:
pip install -r requirements.txt
- Create your private configuration file
Copy the template configuration file to a new file named `config.py`:
cp config_template.py config.py
- Open config.py and add your Telegram bot token and bot name:
BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN"
BOT_NAME = "YourBot"
-
Run the bot
Start the bot with:
-
python main.py
Your bot should now be live on Telegram and ready to respond to commands.
The bot works as follows:
-
Bot Setup
- Connects to Telegram via Bot API using your token.
-
Message Handling
-
Listens for user messages in real-time.
-
Responds to commands like
/start
,/help
,/bye
.
-
-
Private Config
- Your real
config.py
contains the token and bot name. .gitignore
ensures it is never pushed to GitHub.
- Your real
-
config_template.py → included in the repo, safe for public
-
config.py → your private config, never push
-
Example config.py content:
This project is licensed under the MIT License. See the LICENSE file for details.