Choosing the wrong Telegram bot architecture often leads to weeks of rework and thousands of dollars in additional costs. We have seen clients who started with a simple command bot for a complex multi-step order flow, only to hit the 64-byte callback_data limit and have to rewrite everything as a Mini App. Our engineers have built over 30 automated assistants in the last 5 years — from simple broadcast bots to full-blown marketplaces. That experience lets us pick the correct architecture from the start, saving your budget and timeline. Our approach reduces development time by 40% compared to starting from scratch.
Choosing the right bot type: command, Mini App, or conversational
Start with the user scenario. A simple command bot with menus and buttons is fine for order status inquiries or FAQ. You can implement it with InlineKeyboardMarkup and FSM on aiogram or python-telegram-bot. A conversational bot with NLP requires integration with Dialogflow, Rasa, or GPT API for response generation. A full Mini App is a web application (React, Vue, or plain HTML/CSS) inside Telegram's WebView, giving you a custom interface and complex business logic.
| Bot Type | Complexity | Timeline | Examples |
|---|---|---|---|
| Command bot | Low | 1–2 weeks | Order support, FAQ bot |
| Conversational | Medium | 2–4 weeks | Consultant, product recommender |
| Mini App | High | 4–8 weeks | Marketplace, full catalog |
We develop all three types. Most of our clients choose a Mini App with Telegram auth — it provides seamless UX without login/password. According to our metrics, Mini Apps convert 5x more target actions compared to command bots for complex scenarios. Contact us to evaluate your project — we will propose the optimal solution without unnecessary costs. Command bots start at $500, conversational bots from $2,000, and Mini Apps from $5,000.
Why do webhooks beat polling for production?
Telegram Bot API offers two update methods: getUpdates (long polling) and webhooks. Long polling is convenient for local development — just use ngrok to test. But in production, it fills the queue: after a restart, your bot will process thousands of pending updates, potentially blocking the server. A webhook works event-driven: Telegram sends a POST to your HTTPS endpoint, and the bot responds instantly. You save bandwidth and CPU. Our benchmarks show webhooks have 3x lower latency than polling under high load and reduce server load by 80%.
| Criterion | Long polling | Webhook |
|---|---|---|
| Latency | 200-500 ms | 50-100 ms |
| Server load | High (constant requests) | Low (only events) |
| Setup ease | Easy (ngrok) | Requires HTTPS |
Mandatory requirements for webhook:
- Valid TLS certificate (Let's Encrypt or paid)
- Port 443, 80, 88, 8443 (non-standard ports are not supported)
- Unique URL (often use
/{BOT_TOKEN}for isolation)
Example webhook registration with aiogram 3.x:
from aiogram import Bot, Dispatcher
from aiogram.webhook.aiohttp_server import SimpleRequestHandler
bot = Bot(token=BOT_TOKEN)
dp = Dispatcher()
async def on_startup():
await bot.set_webhook(
url="<YOUR_PUBLIC_URL>",
drop_pending_updates=True
)
The parameter drop_pending_updates=True is critical on restart: without it, the bot will process all queued messages, causing a flood.
How to overcome the 64-byte callback_data limit?
Each InlineKeyboardButton has a callback_data limit of 64 bytes. For simple yes/no actions, it is enough. But for complex dialogs (like multi-step flight booking), you will run out of space.
The solution is to store state in Redis with a short identifier and a 1-hour TTL for automatic cleanup:
import uuid, redis, json
r = redis.Redis()
async def create_callback(data: dict) -> str:
callback_id = str(uuid.uuid4())[:8]
r.setex(f"cb:{callback_id}", 3600, json.dumps(data))
return callback_id
async def resolve_callback(callback_id: str) -> dict | None:
raw = r.get(f"cb:{callback_id}")
return json.loads(raw) if raw else None
This approach bypasses the limit and provides a convenient FSM state. Redis automatically cleans expired entries via TTL. This technique is battle-tested on dozens of projects — we guarantee stability and performance.
Verifying initData in Telegram Mini Apps
When your bot runs as a Mini App, window.Telegram.WebApp passes initData — a string with an HMAC signature. The server must validate the signature before trusting user data (telegram_id, username). Otherwise, anyone can forge a request on behalf of another user.
Verification algorithm:
- Derive a secret key: HMAC-SHA256 of
WebAppData(as message) and bot_token (as key). - Parse
initDataby&, sort parameters (excluding hash) by key. - Concatenate them into
data_check_stringusing\naskey=value. - Compute HMAC-SHA256 of
data_check_stringwith the secret key. - Compare the result with the hash from initData.
import hmac, hashlib
def verify_telegram_init_data(init_data: str, bot_token: str) -> bool:
secret_key = hmac.new(b"WebAppData", bot_token.encode(), hashlib.sha256).digest()
params = parse_qs(init_data)
data_check_string = "\n".join(
f"{k}={v}" for k, v in sorted(params.items()) if k != "hash"
)
computed_hash = hmac.new(secret_key, data_check_string.encode(), hashlib.sha256).hexdigest()
provided_hash = params.get("hash", [""])[0]
return hmac.compare_digest(computed_hash, provided_hash)
The algorithm is based on HMAC. Verification takes less than 1 millisecond. After verification, you can use telegram_id to link with your CRM, for example, to associate with an order or subscription. Contact us for design and debugging — we guarantee correct implementation.
What's included in the work: deliverables
We offer a full cycle from idea to deployment. The scope includes:
- Scenario analysis and prototyping
- Stack selection: aiogram, grammy, react-telegram-web-app
- Backend implementation: API, Redis, PostgreSQL (or MongoDB)
- Mini App design adapted to Telegram theme (light/dark)
- Payment integration via Telegram Stars (or external payment gateways)
- Webhook setup with monitoring (uptime, alerts)
- Testing: unit tests, e2e tests against Telegram Bot API
- Debugging and publishing: submission for verification, working with App Store Review Guidelines
Deliverables after completion:
- Full API documentation
- Server credentials and access
- One week of post-launch support
- Monitoring dashboard
We have been building bots of varying complexity for over 5 years. In that time, we have launched over 30 projects — from simple newsletters to marketplaces with hundreds of products via Telegram Mini App. Every project comes with a quality guarantee and technical support. Our packages start at $500 for command bots, $2,000 for conversational, and $5,000 for Mini Apps.
Get started with your bot project
If you have an idea, write to us. We will assess the project, propose an architecture, and give timelines. Expect the following ranges:
- Command bot: from 1 to 2 weeks
- Conversational bot with NLP: from 2 to 4 weeks
- Mini App: from 4 to 8 weeks
Cost is calculated individually, depending on scenario complexity and integrations. Contact us, and we will prepare a technical specification and an accurate estimate. Get a free consultation. Our clients save an average of 30% by choosing the right architecture upfront.







