Step 1: Register the bot
Message @BotFather, send /newbot, choose a display name and a unique username ending in bot. BotFather replies with a token like 123456:ABC-DEF.... Store it as a secret; anyone with the token controls the bot.
While you are there, set /setdescription (shown before the user presses Start), /setabouttext, /setuserpic and /setcommands so the menu shows what the bot can do.
Step 2: Choose a framework
| Framework | Language | Good for |
|---|---|---|
| grammY | TypeScript / Node.js | Most production bots, Mini App companions, serverless deployments |
| aiogram 3 | Python | Teams with Python backends, data-heavy bots, AI integrations |
| python-telegram-bot | Python | Mature, large community |
| Telegraf | Node.js | Legacy projects (grammY is its successor in spirit) |
Step 3: Write the first handlers
import { Bot, InlineKeyboard } from 'grammy';
const bot = new Bot(process.env.BOT_TOKEN!);
bot.command('start', (ctx) =>
ctx.reply('Hi! What would you like to do?', {
reply_markup: new InlineKeyboard()
.text('Book a call', 'book')
.text('Pricing', 'pricing'),
})
);
bot.callbackQuery('pricing', async (ctx) => {
await ctx.answerCallbackQuery();
await ctx.reply('Plans start at $490/month. Want details?');
});
bot.start(); // long polling for development
Model the conversation as states: each message should offer the next step and a way back. Store state per user in a database, not in memory, so restarts and multiple instances do not lose context.
Step 4: Add the features businesses need
- Lead capture: ask for name, email or phone with validation; write to your CRM (CRM integration).
- Notifications: order status, reminders, alerts, sent only to users who started the bot and with rate limits (roughly 30 messages per second across all users).
- Payments: Stars invoices for digital goods; card providers for physical goods (payments).
- Group features: moderation, welcome messages, commands restricted to admins; mind privacy mode, which hides group messages from the bot unless it is an admin or mentioned.
- Inline mode: let users call the bot from any chat with
@yourbot query. - AI answers: connect an LLM with retrieval over your documents (AI chatbots).
Step 5: Deploy with a webhook
In production, register an HTTPS endpoint with setWebhook so Telegram pushes updates to your server. Use a secret token to verify requests, respond within seconds and process heavy work in a queue. Host on any cloud; serverless functions work well for low-volume bots. Keep logs without personal data and set up uptime monitoring.
Step 6: Operate it
Build or use an admin panel to see users, broadcast messages, export leads and watch errors. Review BotFather settings (privacy mode, inline, menu button) and write a short runbook: what to do when the token leaks, when Telegram restricts the bot, when the webhook fails.
When to add a Mini App
Buttons and text carry you far, but catalogs, multi-step forms, dashboards and games need a screen. A Mini App attaches to the same bot and opens from the menu button or any inline button, so nothing in the bot is wasted. See what a Mini App is and how to create one.
If you would rather have it built: Telegram bot development starts at $2,500.
* All prices and ranges on this page are indicative. The final cost is calculated for each project individually and depends on the complexity of the task, the number of developers and specialists required, and the delivery timeline you set. Use the ranges to understand the typical bracket, not as a fixed offer; the fixed price is confirmed in writing after scoping. Read our pricing terms.