Skip to content
TGWAY
Channels & Bots STEP 50 / 99

How to Create a Telegram Bot With BotFather

Every bot mentioned anywhere in this curriculum — the one that posts your feed, the one that issues subscription links, the one moderating your group …

  • LevelL2
In this article
  1. smart_toy Creating one, and the decision that is permanent
  2. key The token is the bot
  3. admin_panel_settings Rights, and the one never to give
  4. touch_app Try it now — five minutes
  5. shield What a bot cannot do
  6. help Common questions at this stage
  7. At a glance
school Telegram Masterclass • Step 086 / 100 Step 086: How to Create a Telegram Bot With BotFather
Step 086 of 100

Every bot mentioned anywhere in this curriculum — the one that posts your feed, the one that issues subscription links, the one moderating your group — was created in a conversation with a bot called BotFather, and is controlled from there afterwards.

The whole subject reduces to one sentence. A bot has no phone and no password; it has a string, and whoever holds the string is the bot. Everything else on this page is a consequence of that.

What you will be able to do after this step

  • check_circle Create a bot and choose the one thing about it you cannot change.
  • check_circle Treat the token as the credential it is, and know how to invalidate it.
  • check_circle Answer honestly when members ask whether the bot reads their messages.
  • check_circle Recognise what a bot is structurally incapable of doing.

smart_toy Creating one, and the decision that is permanent

You open a conversation with BotFather, ask for a new bot, give it a display name, and give it a username. In return you get a token. That is the whole ceremony, and it takes about ninety seconds.

One of those choices does not come back. The display name can be changed whenever you like; the username effectively cannot. It has to be globally unique, it has to end in "bot", and it is what every link, every poster and every mention will point at forever after. Choose it the way you would choose a domain: short, spellable aloud, and not tied to a campaign or a year.

verified
Check that you are talking to the real BotFather There is exactly one, it carries the verification mark, and the imitations exist precisely because people arrive here looking to create something. Anything calling itself BotFather that asks for a login code, a password or an existing token is harvesting credentials. The genuine one never asks you for anything belonging to your account — it only ever gives you things.

Two other pieces of text are worth writing properly on the day you create it, because they are the only things a stranger reads before deciding to press Start: the short description that appears on the bot's empty screen, and the "about" line that appears on its profile. Say what it does and what the first message should contain. This is the same principle as Step 078's free posts — it is the sales material, and it is usually left blank.

key The token is the bot

The token is a single string containing an identifier and a secret. Anything holding it can send what your bot sends, receive what your bot receives, and act with whatever rights your bot has been granted in any room. There is no second factor, no device binding and no login alert.

Which means the handling rules are the ones you would apply to a password with no recovery. It never goes into a repository, a mobile application, a page's code, a screenshot, or a message to a colleague. The most common way tokens escape is not an attack; it is a working file committed to somewhere public, and automated scanning of public code for exactly these strings is a routine activity.

If one escapes, revoke it in BotFather. That invalidates the old string immediately and issues a new one, and whoever copied yours now holds something useless. Note what revoking does not do: it does not remove the bot from your channels or reduce its rights there. If the problem is the bot itself rather than a leaked credential — a service you no longer trust, a tool you stopped using — the action is to remove its administrator rights in each room, which is the control described in Step 085.

Finally, the question of who owns it. The account that created the bot controls it in BotFather. If that is a colleague, a contractor or an old personal account of yours, then the bot's future belongs to that account. Transfer it deliberately while everyone is still on speaking terms rather than discovering the problem when somebody leaves.

You add a moderation bot to your group. A member asks whether it can read the conversation. What is the honest answer?

Your bot's token has been committed to a public code repository. What do you do first?

A bot you have never used sends you a message out of nowhere. What is going on?

admin_panel_settings Rights, and the one never to give

A bot added to a channel or group holds exactly the administrator rights somebody granted it and nothing more. The discipline is the ordinary one: grant the narrowest set that lets it do its job, and review the list occasionally, because rooms accumulate bots from projects that ended.

The right never to grant is the ability to add administrators. A bot with that can promote anything, including something that can remove you. Everything else is recoverable; that one hands over the room. The next most consequential is deletion, which lets a misbehaving automation remove your archive faster than you can stop it.

Worth knowing in the other direction: a bot cannot join anything by itself. Somebody with authority has to add it. That makes the administrator list a complete inventory of what is able to act in your room, which is why Step 085 treats reading that list as the security control it is.

list_alt
The command menu is discoverability, not documentation The list of commands you register with BotFather is what appears when somebody taps the menu in your bot's chat. Three or four that people actually use is a menu; twenty is a wall that gets ignored, after which people ask you questions the bot could have answered. Register the few that matter and explain the rest inside the conversation, where there is room for a sentence.

touch_app Try it now — five minutes

Four steps, and the first two are worth doing even if you never intend to run a bot.

  1. Create a throwaway bot Ninety seconds in BotFather. Seeing the token appear, once, teaches the rest of this page better than reading about it.
  2. Revoke its token and watch a new one arrive Now you know where the emergency control is, which is the point of the exercise.
  3. Open every room you administer and read the bot list Anything you cannot account for, remove. Anything with more rights than it needs, reduce.
  4. Write the description and about text for a bot you already run Two short pieces of text that strangers read before pressing Start, and which are almost always empty.

shield What a bot cannot do

Knowing the boundaries is more useful than knowing the features, both for building and for not being tricked.

It cannot message you first. Covered in the quiz and worth repeating, because it converts a whole family of scams into something you can identify in a second.

It cannot join a room on its own, or see a channel it has not been added to, or read a group it is not in.

It cannot see your phone number, your other chats or your contacts. It knows the account it is talking to and whatever you send it. Some bots ask you to share a contact or a location, and those are explicit prompts you answer — not something taken quietly.

It cannot act outside the rights it was given. A bot with permission to post cannot delete, ban or read the member list, and no amount of code changes that from its side.

And one thing it can do that people forget: anybody who starts a conversation with a bot is identified to whoever runs it. Not your number, but your account, your display name and your username. For an ordinary tool that is unremarkable. For a bot claiming to offer something anonymous, it is worth thinking about, because the operator of that bot is a stranger with a server.

help Common questions at this stage

Can I change my bot's username later?

Treat it as permanent. The display name, the photograph, the description and the commands can all be changed freely; the username is the address everything points at. If you genuinely must move, the practical route is creating a new bot and migrating, which means every existing link, printed code and saved conversation breaks. That is why the ninety seconds spent choosing it is the most consequential part of the creation process.

How many bots can one account create?

Enough that the constraint you hit first is your own ability to remember what they were for. The habit worth forming is deleting the experiments: a bot you made to try something, left in a channel and forgot is a credential you are no longer watching. BotFather can delete a bot outright, and doing so for the abandoned ones is a five-minute piece of hygiene that removes real exposure.

Where should the token actually live?

In whatever your hosting provides for secrets — an environment variable, a secrets store — and nowhere else, particularly not in the file you are editing. The practical test is whether the token would survive being copied into a public place by accident: if the answer depends on you remembering not to, the arrangement is wrong. And if a third-party service needs it, understand that you have given that company the ability to act as your bot for as long as they hold it.

Does a bot need to be an administrator to work in a group?

Only if it needs to act on the room. A bot that answers questions when asked works perfectly well as an ordinary member. A bot that deletes spam, restricts people or pins messages needs the specific rights for those actions — and as the quiz notes, promoting it also removes the message restriction, so a bot made administrator for one small job now receives everything said in the room. That trade should be made knowingly rather than because promotion seemed like the way to get something working.

Can somebody find out what my bot does from the outside?

They can see everything you published about it — name, photograph, description, registered commands — and everything it says to them. They cannot see your code or your data. What they can do is try every command and see what happens, which is worth doing yourself from an account with no privileges, because that is exactly what the first curious stranger will do and it is how administrative commands turn out to be answering anybody.

What happens to a bot if I stop paying for its server?

It stays in every room it was added to and stops responding. Nothing announces this; buttons on old posts do nothing (Step 081), commands fall silent, and any process you built around it quietly stops. If you are winding something down, remove the bot from the rooms as part of the shutdown, and if you inherit a channel with a silent bot on the administrator list, the fact that it does nothing today is not a reason to leave the credential in place.

Summary

At a glance

How to Create a Telegram Bot With BotFather — at a glance illustration
  1. 1Create with BotFather

    Choose the username carefully; it cannot be changed later.

  2. 2The token is the bot

    Anyone with it controls the bot; revoke it if it leaks.

  3. 3Honest about reading

    By default a bot sees only messages meant for it; admin bots see all.

Share this guide

Send it to a friend who has the same question.

Telegram WhatsApp
More

Open on your phonePoint your phone camera here to open this guide.

Updated

Related articles

View all ›