Telegram Bot API Basics 2026 โ BotFather, Token, First /start, Deploy
Building a working Telegram bot in 2026 takes around 30 minutes. There is no developer registration like Apple's โ all you need is a Telegram account, BotFather, and any hosting (free tier is fine). Here is the full walkthrough.
Step 1. Get a token from BotFather
- Find @BotFather in Telegram (official, blue checkmark).
- Send
/newbot. - Set a display name: "My First Bot".
- Set a username โ must end in
bot. Example:myfirst_2026_bot. - BotFather returns a token like
7654321098:AAH-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Never share the token โ it's the bot's password. If leaked, use /revoke to rotate it.
Step 2. First /start handler in Python
Install python-telegram-bot (the 2026 standard is version 21):
pip install python-telegram-bot==21.7
Create bot.py:
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes
TOKEN = "7654321098:AAH-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text(
f"Hi, {update.effective_user.first_name}! I'm your first bot."
)
app = Application.builder().token(TOKEN).build()
app.add_handler(CommandHandler("start", start))
app.run_polling()
Run python bot.py, find your bot in Telegram, hit Start, and get a reply.
Step 3. Useful BotFather commands
| Command | What it does |
|---|---|
/setdescription |
Profile description |
/setabouttext |
Short "about" text |
/setuserpic |
Avatar |
/setcommands |
Command list (appears in Telegram menu) |
/setinline |
Enable inline mode |
/setjoingroups |
Allow adding the bot to groups |
/setprivacy |
Whether the bot sees all group messages |
Step 4. Deploy the bot
Local Python runs only while your script is alive. For 24/7 operation you need hosting. Top 2026 options:
- Railway.app โ $5/mo, GitHub deploy in 2 minutes. Best beginner choice.
- Render.com โ has a free tier but "sleeps" after 15 idle minutes.
- Fly.io โ $0-3/mo, slightly more setup.
- Generic VPS (Hetzner, Vultr) โ $3-5/mo, full control but you configure systemd yourself.
Railway steps:
- Create a GitHub repo with
bot.pyandrequirements.txt. - Sign in at railway.app via GitHub.
- New Project โ Deploy from GitHub repo.
- Add
TOKENto environment variables. - Change
TOKEN = "..."toTOKEN = os.environ["TOKEN"].
Two minutes later your bot is running 24/7.
Step 5. What to add next
- Stars payments โ built-in API, no Stripe required.
- Inline mode โ call your bot in any chat with
@yourbot. - Mini Apps โ full HTML + JS web apps inside Telegram.
- Webhooks instead of polling โ far more efficient at scale.
Premium account for testing
For testing Stars payments, Mini Apps, and extended API features it helps to have Premium on a test account. On Marix you get Premium in your local currency in a few minutes โ no foreign card needed. That's the standard infrastructure for any Telegram developer in 2026.

