Every Telegram bot starts the same way: a conversation with Telegram BotFather, the official bot that creates and manages all other bots. In about two minutes you get a bot account and an access token. What the bot actually does is up to the code you connect to that token. This guide covers creating the bot, configuring its profile, keeping the token safe and sending your first message through the Bot API.
You do not need programming skills for the first part. The later steps assume you are comfortable opening a URL or running a small script.
Step 1: open BotFather
Search for @BotFather in Telegram. The real one has a verification checkmark next to its name. Many lookalike accounts exist, so make sure you pick the official one before you continue. Open the chat and press Start. BotFather replies with a list of commands it understands.
Step 2: create the bot
- Send
/newbot. - Choose a name. This is the display name people see in chats, such as "Book Club Helper". You can change it later.
- Choose a username. It must be unique and end in "bot", for example
bookclub_helper_botorBookClubHelperBot. Usernames use Latin letters, numbers and underscores. If the name is taken, BotFather asks you to try another. - Copy the token. BotFather sends a message with your bot's link (
t.me/yourbotusername) and an HTTP API token that looks like a number, a colon and a long string of characters.
Your bot now exists. If you open its link and press Start, nothing will happen yet, because no code is answering it.
Step 3: protect your token
The token is the bot's password. Anyone who has it can control the bot completely: read the messages it receives, send messages as it and act in every group where it is an admin.
- Never paste the token in a group, a screenshot, a public repository or a support chat.
- Store it in an environment variable or a secrets manager rather than in your source code.
- If you think it leaked, use BotFather to revoke it and generate a new one (through
/mybots, then your bot's API token options, or with/revoke). The old token stops working immediately.
Step 4: set up the bot's profile and behavior
BotFather manages everything about your bot that is not code. Send /mybots, pick your bot and use the menu, or use commands directly.
| Command | What it changes |
|---|---|
/setname | The display name |
/setdescription | The text shown in an empty chat before someone presses Start |
/setabouttext | The short bio on the bot's profile |
/setuserpic | The profile photo |
/setcommands | The command list users see when they type "/" |
/setjoingroups | Whether the bot can be added to groups |
/setprivacy | Privacy mode: whether the bot sees all group messages or only those meant for it |
/deletebot | Deletes the bot permanently |
A clear description and command list make a big difference: they are the first thing a new user sees. For tips on naming and structuring commands, see Telegram bot commands basics. Before changing privacy settings, read Telegram bot privacy mode explained.
Step 5: test the Bot API
You can check that your token works without writing any code. Open this URL in a browser, replacing the placeholder with your token:
https://api.telegram.org/bot<YOUR_TOKEN>/getMe
Telegram returns a short JSON response with your bot's ID, name and username. If you see an error, the token is wrong or was revoked.
To send a message, the bot needs a chat ID, and users must start a conversation with the bot first; bots cannot message people out of the blue.
- Open your bot's chat and send it any message.
- Visit
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates. Find thechatobject in the response and note itsid. - Visit
https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage?chat_id=<ID>&text=Hello. The message appears in your chat.
Avoid sharing these URLs, since they contain your token.
Step 6: connect real code
A bot needs a program that receives updates and responds. There are two ways to receive updates:
- Long polling with
getUpdates: your program repeatedly asks Telegram for new updates. Easy to start with, works from a laptop, no public server needed. - Webhooks with
setWebhook: Telegram sends updates to an HTTPS URL you provide. Better for production, but you need a server with a valid certificate.
You use one method at a time; while a webhook is set, getUpdates does not work. Most developers use a library for their language rather than raw HTTP calls, since libraries handle updates, commands and keyboards for you. Well-maintained open-source libraries exist for most popular languages. If you get stuck, developer communities in the programming section of the Grupla directory are a good place to ask questions.
When your code runs on a server that stays online, your bot is live. From there you can add it to groups (see how to add a bot to a Telegram group) or build a web interface with Telegram Mini Apps.
Good first projects and common mistakes
If you are learning, start with something small that you will actually use. A few ideas that teach the basics of the Bot API without much complexity:
- An echo or FAQ bot that answers a handful of commands with fixed text, such as your group's rules or opening hours.
- A reminder bot for yourself that sends a message at a set time each day.
- A feed bot that posts new items from a website to your own channel.
The mistakes beginners make most often are predictable: committing the token to a public code repository, forgetting that the bot stops answering when the laptop running it goes to sleep, and expecting the bot to see every group message while privacy mode is on. Avoid those three and most early problems disappear.
Frequently asked questions
Is creating a Telegram bot free?
Yes. Creating a bot with BotFather and using the Bot API costs nothing. You only pay for wherever you host your bot's code, if you use a paid server.
Can I change my bot's username later?
The display name, description and picture are easy to change in BotFather. Treat the username as permanent, because links and integrations depend on it.
Why doesn't my bot reply?
The bot only replies when your code is running and receiving updates. Check that your program is online, that the token is current and that a webhook is not blocking polling.