First Telegram Bot in Python
Brief
Minimal path to your bot: registration with BotFather, library installation, 20 lines of code.
1. Get the Token
- Find @BotFather in Telegram.
- Send
/newbotand follow the instructions. - Save the issued token.
2. Install the Library
pip install python-telegram-bot
3. Write the Bot
from telegram.ext import Application, CommandHandler
async def start(update, context):
await update.message.reply_text("Hello! I am working!")
app = Application.builder().token("YOUR_TOKEN").build()
app.add_handler(CommandHandler("start", start))
app.run_polling()
4. Run
python bot.py
Now the bot responds to the /start command.
How to Add AI
The bot can communicate with LLM via API — for example, DeepSeek. Then it becomes not just an "echo", but a full-fledged conversationalist. This is the first step towards agents.