Build a Telegram Bot: Day 2 - Interactive Telegram Bot
Level: Intermediate
Projects in this week’s series:
This week, we progressively build a Telegram bot from basic messaging to AI-powered conversations.
Day 1: Send Telegram Messages with Python
Day 2: Interactive Telegram Bot (Today)
Day 3: AI-Powered Bot with Gemini
Today’s Project
Yesterday we built a script that sends messages to Telegram. Today we’re making it interactive — the bot will listen for messages, respond to commands, handle user input, and have real two-way conversations!
Important: Today’s bot is rule-based, not AI. This means it responds based on specific commands and keyword patterns you program, rather than understanding language like ChatGPT. Think of it like a smart vending machine — press the right button (/start, /help, /joke) and you get a specific pre-programmed response.
Why start with rule-based? Because it teaches you the fundamentals of bot development: handling commands, processing messages, managing callbacks, and conversation flow. Tomorrow we’ll upgrade it to AI-powered intelligence with Gemini!
We’re transforming a one-way message sender into a fully interactive chatbot!
Project Task
Create an interactive Telegram bot that:
Listens for incoming messages continuously
Responds to commands (/start, /help, /about, /menu, /joke, /time, /echo)
Handles text messages with keyword detection
Provides menu-based interaction with clickable buttons
Responds to button clicks (callback queries)
Shows typing indicator while processing
Handles multiple users simultaneously
Logs all interactions to console
How it works: The bot uses pattern matching — it checks if your message contains specific keywords (like “hello”, “time”, “joke”) and responds with pre-written replies. It’s fast, reliable, and doesn’t cost anything to run, but it can’t understand complex questions or learn from conversations.
This project gives you hands-on practice with webhook polling, command handlers, callback queries, conversation management, and building interactive bots — essential skills for chatbot development!
Understanding Rule-Based vs AI Bots
Today’s bot is RULE-BASED:
✅ Responds to specific commands (/start, /joke, /time)
✅ Detects keywords (”hello”, “time”, “joke”)
✅ Fast, free, and reliable
❌ Can’t understand complex questions
❌ Can’t learn or adapt
❌ Limited to programmed responses
Example of what works:
User: "hello" → Bot: "Hello! 👋"
User: "what time is it" → Bot: "The time is 14:30"
User: "tell me a joke" → Bot: [sends joke]
Example of what doesn’t work:
User: "Why is the sky blue?" → Bot: "I received your message..."
User: "Write me a poem" → Bot: "I received your message..."
User: "Explain recursion" → Bot: "I received your message..."
Think of it like a vending machine: Press button A (command /joke), get item A (a joke). Press button B (keyword “time”), get item B (current time). Try to ask for something not on the menu? Generic fallback response.
Expected Output
When you run the program, in the terminal, you will receive the messages a Telegram user sends to the bot:
In Telegram (User’s View):
And here is the conversation the user is having on Telegram with your bot:
Coming Tomorrow
Tomorrow we’re upgrading to an AI-Powered Bot with Google Gemini — it will understand ANY question, have intelligent conversations, remember context, generate creative responses, and actually be useful for real questions! We’re replacing keyword matching with true language understanding!
The bot will transform from:
“I received your message”to
Actual intelligent answers to any question
View Code Evolution
Compare today’s solution with earlier versions and see how we’re building a complete Telegram bot system.
Keep reading with a 7-day free trial
Subscribe to Daily Python Projects to keep reading this post and get 7 days of free access to the full post archives.



