Last checked . Telegram rules checked against Telegram's documentation: Telegram Bots: introduction, Telegram Bots: tutorial, Telegram Bot Features, Telegram Bot API, Telegram Bots FAQ, Payments in Telegram Stars, Bot Features: BotFather, Bot Features: privacy mode, Bot API: setMyCommands. Bot commands, limits and prices come from the bots' own data, verified .
On this page ⌄
- 01Step 1: create the bot with @BotFather
- 02Step 2: choose how your bot gets updates
- 03Step 3: a hello-world bot on a Cloudflare Worker
- 04Step 4: make the bot work in groups
- 05Step 5: take payments with Telegram Stars
- 06What 35 small bots taught the maker of this site
- 07Don’t want to build it yourself?
- 08Common problems
A Telegram bot is a normal Telegram account that your code controls. You create it in a chat with @BotFather, you get a token, and from then on your server talks to Telegram over plain HTTPS requests. You do not pay Telegram anything to start.
This guide takes you from an empty chat with @BotFather to a bot that replies, works in groups and takes payments in Telegram Stars.
Step 1: create the bot with @BotFather
You create a Telegram bot by sending /newbot to @BotFather, the Telegram bot that creates and manages bots. It asks for a display name and a username that ends in “bot”, then replies with a token. The token is the key to your bot, so keep it as secret as a password. The whole step takes six short actions.
- Open @BotFather. Search for
@BotFatherin Telegram and press Start. - Send
/newbot. BotFather asks for a name first. This is the display name, for example “Recipe Helper”. You can change it later with/setname. - Pick a username. It must end in “bot”, like
tetris_botorTetrisBot. Usernames are 5 to 32 characters long, use only Latin letters, numbers and underscores, and are not case sensitive. - Save the token. BotFather replies with a token that looks like
110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw. Anyone with this token can control your bot. Do not put it in a public repo, a screenshot or a chat. - Set up the profile. Use
/setdescriptionfor the text people see before they press Start (up to 512 characters),/setabouttextfor the short bio (up to 120 characters) and/setuserpicfor the picture. - Register your commands. Send
/setcommandsand give one line per command, for examplestart - Start the bot. Telegram shows these in the command menu.
Warning: If your token leaks, send
/tokento @BotFather to generate a new one. The old token stops working, so update your server at once.
Other BotFather commands you will use: /mybots opens a menu for all your bots, /setprivacy sets which group messages your bot receives, /setjoingroups controls whether the bot can be added to groups, /setinline turns on inline mode, and /deletebot deletes the bot and frees its username (this cannot be undone). Telegram also asks every bot to support /start, /help and, if it has settings, /settings.
Step 2: choose how your bot gets updates
Your Telegram bot receives each message, button tap or payment as an “update”, in one of two ways. With getUpdates, your code asks Telegram for new updates. With setWebhook, Telegram sends each update as an HTTPS POST to your URL. The Bot API lets you use only one of them at a time.
| Method | How it works | Good for |
|---|---|---|
getUpdates | Your code asks Telegram for new updates, with a timeout for long polling | Local testing, a script on your own computer |
setWebhook | Telegram sends each update as an HTTPS POST to your URL | Servers and serverless hosts |
While a webhook is set, getUpdates does not work. To go back to polling, call setWebhook with an empty url. Telegram keeps pending updates for at most 24 hours, so a bot that is down for longer loses them. Webhooks work only on ports 443, 80, 88 and 8443.
Step 3: a hello-world bot on a Cloudflare Worker
A hello-world Telegram bot fits in about 20 lines of TypeScript on a Cloudflare Worker. The Worker reads the update JSON that Telegram posts to it, then calls sendMessage with a reply. This one answers /start, echoes any other text and checks a secret header first, so only Telegram can call it.
export interface Env { BOT_TOKEN: string; WEBHOOK_SECRET: string }
export default {
async fetch(request: Request, env: Env): Promise<Response> {
if (request.method !== "POST") return new Response("ok");
// Telegram sends the secret_token from setWebhook in this header.
if (request.headers.get("X-Telegram-Bot-Api-Secret-Token") !== env.WEBHOOK_SECRET) {
return new Response("forbidden", { status: 403 });
}
const update: any = await request.json();
const msg = update.message;
if (msg?.text) {
const text = msg.text.startsWith("/start") ? "Hello! Send me any text." : `You said: ${msg.text}`;
await fetch(`https://api.telegram.org/bot${env.BOT_TOKEN}/sendMessage`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ chat_id: msg.chat.id, text }),
});
}
return new Response("ok");
},
};
Store both values as Worker secrets (wrangler secret put BOT_TOKEN and wrangler secret put WEBHOOK_SECRET), deploy, then point Telegram at the Worker URL:
curl "https://api.telegram.org/bot$BOT_TOKEN/setWebhook" -d "url=https://your-worker.example.workers.dev" -d "secret_token=$WEBHOOK_SECRET"
The secret token can be 1 to 256 characters, and only A-Z, a-z, 0-9, _ and - are allowed. Open your bot, press Start, and it replies.
Tip: Return a 2xx status for every real update, even one you ignore. If your webhook returns an error, Telegram repeats the request and gives up after some attempts.
Step 4: make the bot work in groups
By default a bot in a group runs in privacy mode. It then receives only commands meant for it (such as /command@your_bot), replies to its own messages, messages sent through it, and service messages such as joins. It does not see normal chat.
You have two ways to let it see more:
- Make it an admin. Bot admins always receive all messages, except messages from other bots. Give it only the rights it needs. A member check like Group Gate, for example, needs only “Ban users” and “Delete messages”.
- Turn privacy off. Send
/setprivacyto @BotFather and choose Disable. Then remove the bot from the group and add it again so the change takes effect there.
No bot sees messages from other bots, in any mode. For the steps in the app, see how to add a bot to a group and give it admin rights.
Step 5: take payments with Telegram Stars
A Telegram bot that sells digital goods or services must take payment in Telegram Stars, with currency XTR. The flow has 4 parts: send an invoice, answer the pre-checkout query within 10 seconds, deliver only after successful_payment, and support /paysupport. Payment providers for cards are only for physical goods and services.
- Create the invoice. Call
sendInvoiceto send it into a chat, orcreateInvoiceLinkto get a link. Setcurrencyto"XTR"and pass an empty string asprovider_token. - Answer the pre-checkout query. When the user presses Pay, you get a
pre_checkout_queryupdate. CallanswerPreCheckoutQuerywithin 10 seconds, or the payment is cancelled. - Deliver after
successful_payment. Only this message confirms the payment. Do not unlock anything before it arrives. - Support
/paysupport. Telegram requires bots that take payments to answer this command and help with payment problems. You also need terms the user can reach, for example with/terms. You can refund withrefundStarPayment.
For the full flow, read the Stars developer guide.
What 35 small bots taught the maker of this site
All bots listed on this site come from one maker, who also runs this site. Each bot does one job, and a hub bot, Tiny Telegram Tools, is “the hub bot that opens the tools in one menu.” A few design choices repeat across them:
- Free first, Pro once. Each bot with a full page here has a free plan with clear limits, and a Pro upgrade paid in Stars with
/pro: 150 Stars (about $3) for most, 75 Stars (about $1.50) for a few. The Pro page lists them all. Some bots also offer a monthly Stars subscription next to the one-time payment. - Pick the right scope. Pro applies per group for group tools (16 bots), per user for personal tools (12), and per chat for two bots, such as Giveaway Draw. Decide this before you write the payment code.
- Plan for “a bot cannot write first”. A bot cannot start a chat with a person. So the party game bots ask each player to open a private chat once before they can get a secret role, and Giveaway Draw asks people to press Start in the bot when they tap Join.
- A real
/paysupport. In Group Gate,/paysupportlets you describe a payment problem, and the message goes to the maker. - Write down what you store. Each bot page lists its privacy notes. Group Gate, for example, checks message text only for members who joined less than 24 hours ago, and it does not store that text.
Free to start. Pro is a one-time 150 Stars (about $3.00) per chat. Send /pro in the bot.
Don’t want to build it yourself?
If you need a bot but not the work of running it, you can hire the maker of this site to build it. If you already run a bot and want people to find it, you can list your bot on this site.
Common problems
When a new Telegram bot does not reply, call getWebhookInfo with your token first. It shows the URL Telegram uses to reach your bot and the last error it got. Two other causes come up often: a webhook that blocks getUpdates, and a user who never pressed Start in the bot. The fixes are below.
- The bot does not reply. Call
getWebhookInfowith your token. It shows the URL Telegram uses and the last error. getUpdatesreturns an error. A webhook is still set. Remove it withsetWebhookand an emptyurl, or use only the webhook.- The bot cannot message a user. The user never pressed Start. Send them a link to the bot first.
Key terms
- BotFather
- @BotFather is the Telegram bot that creates bots and manages their settings, with commands such as /newbot, /setcommands, /setprivacy and /mybots.
- Bot token
- The secret key BotFather gives you for one bot. Anyone with the token can control the bot. Send /token to BotFather to replace a leaked one.
- Webhook
- An HTTPS URL you register with setWebhook. Telegram sends each update to it as a POST request, so your code does not have to ask for updates.
- Privacy mode
- The default setting for bots in Telegram groups. The bot sees only commands for it, replies to it, messages sent through it and service messages. Admin bots see all messages.
- XTR
- The currency code for Telegram Stars in the Bot API. Invoices for digital goods use currency XTR and an empty provider_token.
Questions people ask
Is it free to create a Telegram bot? +
Yes. @BotFather creates the bot and the token at no cost, and the Bot API has no fee. You pay only for the server or hosting that runs your code.
Do I need to know how to code to make a Telegram bot? +
To build your own logic, yes, at least a little. The hello-world in this guide is about 20 lines of TypeScript. If you do not want to code, you can hire someone or use a bot that already does the job.
Why does my bot not see messages in my group? +
Privacy mode is on by default. Then the bot gets only commands meant for it, replies to its messages and a few other cases. Make the bot an admin, or turn privacy off with /setprivacy in @BotFather and add the bot to the group again.
Can my bot take card payments for digital goods? +
No. Telegram requires Telegram Stars (currency XTR) for digital goods and services. Card payments through a payment provider are only for physical goods and services.
Pro is paid once in Telegram Stars, inside each bot. No account and no card on this site. The Pro page lists every bot's price and what Pro adds.
⭐ See every Pro upgrade