How to create a Telegram bot with BotFather

Published
Checked
Reading
4 min
Sources
5 named

In short

  • Open @BotFather, Telegram's official bot for creating bots, send /newbot, then choose a display name and a username.
  • The username must be 5 to 32 characters, use Latin letters, digits and underscores, end in 'bot', and can't be changed later.
  • BotFather gives you a token. Anyone with it controls the bot, so treat it like a password; /token makes a new one.
  • Without code, a bot does nothing. You can test it from a browser through the Bot API, then write a program that keeps running on a computer or server.

To create a Telegram bot, open @BotFather in Telegram, send /newbot, and answer two questions: the bot's display name and its username, which must end in "bot". BotFather then gives you a token, a long string that lets your program control the bot. Telegram says a bot needs no phone number to set up. Making it actually reply takes some code running on a computer that stays online.

All of this comes from Telegram's developer documentation and FAQ, checked on 22 November 2026. We are not affiliated with Telegram. If you only want to use bots rather than build one, our guide to Telegram bots is the better start.

Steps: Step 1: create the bot in @BotFather. 1) Open the chat with @BotFather. 2) Send /newbot. 3) Type the display name. This is what people see in chats and contact details, and you can change it later. 4) Type the username. It's used in search, mentions and t.me links. 5) BotFather creates the bot and gives you its token.Steps: Step 1: create the bot in @BotFather. 1) Open the chat with @BotFather. 2) Send /newbot. 3) Type the display name. This is what people see in chats and contact details, and you can change it later. 4) Type the username. It's used in search, mentions and t.me links. 5) BotFather creates the bot and gives you its token.

Step 1: create the bot in @BotFather

@BotFather is Telegram's own tool for creating and managing bots. Search for it in Telegram by its exact username and open that chat.

  1. Open the chat with @BotFather.
  2. Send /newbot.
  3. Type the display name. This is what people see in chats and contact details, and you can change it later.
  4. Type the username. It's used in search, mentions and t.me links.
  5. BotFather creates the bot and gives you its token.

BotFather also has a mini app with the same functions in a regular interface, if you'd rather tap than type commands.

Username rules

Telegram's documentation sets these rules for bot usernames:

Rule Detail
Length 5 to 32 characters
Allowed characters Latin letters, digits, underscores
Case Not case-sensitive
Ending Must end in "bot", like tetris_bot or TetrisBot
Changing it later Not possible; only the display name can change
Add this table to your site

Free to use on your site, blog or newsletter. Copy the code below and paste it into your page as HTML. It shows the same table with a link back to this page as the source.

The username must be free. If BotFather says it's taken, try another. Deleting a bot with /deletebot frees its username, but that can't be undone.

Step 2: keep the token safe

The token looks like a number, a colon and a long run of letters and digits. Telegram's tutorial says to treat it like a password and share it with nobody: anyone who has it can control your bot.

If it leaks or you lose it, send /token to @BotFather and generate a new one, then put the new one into your code.

Step 3: check that the bot works, from a browser

Telegram's Bot API answers ordinary web requests, and its tutorial suggests trying it straight from a browser. Replace TOKEN with your token in each address below. Keep in mind the token will sit in your browser history; on a shared computer, use a private window.

  1. Check the bot exists: open https://api.telegram.org/botTOKEN/getMe. The reply, in JSON, shows "ok": true and your bot's name and username.
  2. Write anything to your bot in Telegram. Bots can't start a conversation, so you go first.
  3. See what the bot received: open https://api.telegram.org/botTOKEN/getUpdates. Your message is there, and inside it the chat's "id".
  4. Make the bot answer: open https://api.telegram.org/botTOKEN/sendMessage?chat_id=ID&text=Hello with that id. "Hello" arrives in your chat from the bot.

Note the word "bot" glued in front of the token in every address. That is how the Bot API expects it.

Step 4: write the code that makes it reply

A browser can't watch for new messages, so a real bot is a program that does it for you. Telegram's Bot API offers two ways to receive messages, and a bot uses one or the other:

  • getUpdates (long polling): your program keeps asking Telegram for new updates. Simple, and it works from a home computer.
  • Webhooks: Telegram sends each update to an HTTPS address on your server.

Either way, Telegram keeps undelivered updates for no more than 24 hours. Telegram's own step-by-step tutorial builds a bot in Java, with the same examples available in C#, Python, Go and TypeScript, using libraries instead of raw requests. It starts with a bot that echoes back what you send, then adds commands, menus and buttons.

Telegram doesn't store your bot's data for you. Once your program has handled an update, it's gone from the server, so anything you need to remember, such as user settings, goes in your own database.

Step 5: keep the bot online

If your bot runs on your laptop, it stops answering when the laptop sleeps. Telegram's tutorial suggests moving it to a machine that's always on, such as a rented virtual server, and keeping user data encrypted there. Bots also have no "last seen" status; people see a "bot" label instead.

Set up the bot's profile and commands

Back in @BotFather, a few commands make the bot easier to understand:

  • /setdescription: the "What can this bot do?" text people see before they start, up to 512 characters.
  • /setabouttext: the short bio on the bot's profile, up to 120 characters.
  • /setuserpic: the profile picture.
  • /setcommands: the list of commands people see when they type a slash.
  • /mybots: edit all of this in menus, or transfer the bot to another person who has used it at least once.

To test changes without disturbing real users, Telegram suggests making a second bot in BotFather and running your test code on it.

Bots in groups, and payments

Added to a group, a bot runs in privacy mode by default and sees only commands and messages meant for it, unless it's an admin. You can turn privacy mode off, but Telegram recommends doing so only when the bot really needs every message, and members can see the setting in the group's member list. A bot added to a channel receives all of that channel's posts; see our guide to creating a Telegram channel.

Bots and mini apps can sell digital goods and services for Telegram Stars, and mini apps can send Telegram gifts as rewards. Telegram's FAQ notes that every bot and mini app must have a privacy policy, and if a developer hasn't published one, Telegram's standard bot privacy policy applies.

Questions people ask

Is it free to create a Telegram bot?

Telegram's FAQ calls the Bot API free, and its bot page says the platform is free for users and developers. What may cost money is the server that runs your bot's code around the clock; Telegram's tutorial mentions renting one.

Can I create a Telegram bot without coding?

Telegram's FAQ says non-developers can use AI bots that create and manage other bots for them, and there are ready-made bots made by others. For a bot that does something of your own, some programming is needed.

What do I do if my bot token leaks?

Send /token to @BotFather and pick the bot to generate a new token. Telegram warns that anyone who has the token can control your bot.

Can I change my bot's username later?

No. Telegram's docs say the bot's name can be changed, but the username can't, so choose it carefully. /deletebot frees the username but can't be undone.

Can my bot message people first?

No. Telegram says bots can't start conversations: a person has to message the bot or add it to a group first.

Sources

  1. Telegram Bot Features: BotFather, Telegram
  2. From BotFather to 'Hello World', Telegram
  3. Telegram Bot API, Telegram
  4. Bots: An introduction for developers, Telegram
  5. Telegram FAQ: Bots and Mini Apps, Telegram

How we write these pages