AI Telegram Bot in 2026: python-telegram-bot (29k Stars) vs aiogram vs grammY - Build an LLM Bot in 15 Minutes
Telegram has the friendliest bot API of any chat app. python-telegram-bot (29,383 stars), aiogram (5,818) and grammY (3,705) all connect to it - here is how to pick and build an LLM bot fast.
💡 What You Will Learn
Telegram has the friendliest bot API of any chat app. python-telegram-bot (29,383 stars), aiogram (5,818) and grammY (3,705) all connect to it - here is how to pick and build an LLM bot fast.
📜 Table of Contents
The short answer
python-telegram-bot (29,383 stars, GPL-3.0) is the most battle-tested Python wrapper - great docs, huge community, sync or async. aiogram (5,818 stars, MIT) is the modern async choice: faster, cleaner code, FSM support for multi-step dialogs. grammY (3,705 stars, MIT) is the TypeScript framework with a plugin ecosystem.
15-minute bot with python-telegram-bot
pip install python-telegram-bot openai
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters
import openai
TOKEN = "YOUR_BOT_TOKEN"
async def chat(update: Update, context):
r = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": update.message.text}])
await update.message.reply_text(r.choices[0].message.content)
app = Application.builder().token(TOKEN).build()
app.add_handler(MessageHandler(filters.TEXT, chat))
app.run_polling()
Get the token from @BotFather: /newbot - name - token.
Picking the right framework
| Framework | Stars | Language | Best for |
|---|---|---|---|
| python-telegram-bot | 29,383 | Python | Docs, stability, sync/async |
| aiogram | 5,818 | Python | Async, multi-step dialogs (FSM) |
| grammY | 3,705 | TypeScript | Plugins, session middleware |
Real numbers
run_polling()handles thousands of users on one process - Telegram's API is pull-based, no webhooks needed for small bots.- A bot replying via LLM API costs roughly $0.0002-0.004 per message with gpt-4o-mini-class models, or $0 with local Ollama.
- python-telegram-bot receives about 1 million downloads per month.
FAQ
Q: Webhook or polling? A: Polling is fine up to ~10k users. Above that, use webhooks with a domain and HTTPS.
Q: Can the bot remember conversations? A: Yes - store message history per user in a dict, Redis, or SQLite, and send the last N messages as context.
❓ FAQ
Webhook or polling?
Polling is fine up to ~10k users. Above that, use webhooks with a domain and HTTPS.
Can the bot remember conversations?
Yes - store message history per user in a dict, Redis, or SQLite, and send the last N messages as context.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only โ no paid placements.
