How to create a Telegram bot: step by step, code or no code
Register a bot in @BotFather in a minute, then make it answer: a ready service, your own Python code with an example, or AI. Setup, hosting, groups, fixes.
Launching a channel? Start with a bot
Connect a botTL;DR. A Telegram bot is an account plus a program that answers for it. The account takes a minute: open @BotFather, send
/newbot, pick a name and a username ending inbot, and you get a token. The program is a separate step: connect the bot to a ready service, run your own code (a short Python example is below), or ask an AI assistant to write it. Until the program runs, the bot stays silent.
Almost every “how to create a Telegram bot” guide ends at the token from BotFather. At that point the bot can’t do anything yet. Telegram describes bots exactly that way: special accounts connected to their owner’s server, which processes the messages. Below is the whole path, from registration to a bot that answers, with setup, hosting and the mistakes people get stuck on most.
Step 1. Register the bot in @BotFather
- Open @BotFather — Telegram’s official bot for creating bots — and press Start. It works the same on a phone and on a computer.
- Send
/newbot. - Send a name. It shows in chats and contacts and can be changed at any time.
- Send a username: 5–32 Latin letters, digits and underscores, ending in
bot(tetris_bot,TetrisBot). Case does not matter, and the username cannot be changed later. If it is taken, BotFather asks for another one; you can check beforehand whether it is already taken in the username checker. - BotFather replies with the token, a string like
110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw.
The token is a key: whoever knows it controls the bot. Don’t publish it, and don’t write it into code you put online. How to find the token later, check it and revoke a leaked one is covered in the bot token guide.
The BotFather Mini App does all of this too, with buttons instead of commands.
Step 2. Set up the bot’s profile
Someone who opens the bot for the first time sees its name, picture and description before the first message. All of it is set in @BotFather — with the commands below or through /mybots → your bot — and some of it can be edited right on the bot’s profile page.
| Command | What it sets | Where people see it |
|---|---|---|
/setuserpic | the profile picture | in the chat list and on the profile |
/setdescription | a description of up to 512 characters | in the empty chat with the bot, until the person writes to it |
/setabouttext | a short text of up to 120 characters | on the bot’s profile and next to the link when the bot is shared |
/setcommands | the list of commands with descriptions | as suggestions when the person types / |
/setname | the name | everywhere the bot appears |
The description and the short text can be set in several languages — with the Bot API methods setMyDescription and setMyShortDescription and a language_code — and each person sees the version in their Telegram’s language.
Step 3. Teach the bot to answer
This is where most guides stop. Telegram only delivers messages to the bot; what answers them is the program you gave the token to. There are three ways to get one:
| Ready service | Your own code | Code with an AI assistant | |
|---|---|---|---|
| Coding needed | no | yes | a little: run it and check it |
| Where the program runs | at the service | on your computer or server | on your computer or server |
| Who fixes it when the bot goes down | the service | you | you |
| What the bot can do | what the service can do | anything you write | anything you write and check |
A ready service
These are conversation builders and platforms where the bot’s job — a shop, a paid channel, support — is already built. You connect the bot, and the program and the server stay on the service’s side. Which one fits which job is covered in creating a bot without code.
If the bot is for a channel, AdminHub can create it right from the app. Telegram lets one bot create others — managed bots — so you only pick a name and a username in a Telegram window, and the app receives the token from Telegram itself, without you copying it. If the handover does not finish or the bot already exists, you paste the token by hand. Both paths are shown in the guide to creating a bot for your channel.
Your own code: a bot in Python
The example uses aiogram 3, one of the Bot API libraries on Telegram’s code examples page. The bot greets you on /start and repeats your messages back.
- Install Python 3.10–3.14 (aiogram does not support 3.15 yet). In a terminal, create a virtual environment and install the library:
python3 -m venv .venv
source .venv/bin/activate
pip install aiogram
On Windows: python -m venv .venv, then .venv\Scripts\activate, then pip install aiogram.
- Save the code as
bot.py:
import asyncio
import os
from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
from aiogram.types import Message
dp = Dispatcher()
@dp.message(CommandStart())
async def start(message: Message) -> None:
await message.answer(f"Hi, {message.from_user.first_name}! Send me any message and I will repeat it.")
@dp.message()
async def echo(message: Message) -> None:
await message.copy_to(message.chat.id)
async def main() -> None:
bot = Bot(token=os.environ["BOT_TOKEN"])
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())
- In the same terminal window, pass the token in an environment variable instead of writing it into the code (Telegram’s tutorial advises the same), and run the program:
export BOT_TOKEN="token from BotFather"
python bot.py
On Windows, instead of export: set BOT_TOKEN=token in the Command Prompt or $env:BOT_TOKEN="token" in PowerShell.
Open the bot in Telegram and press Start: it answers. Stop the program (Ctrl+C) and the bot goes silent. Try the code on a separate bot: a bot already connected to a service has a webhook set, and polling will not work for it. Other popular libraries from the same list are python-telegram-bot for Python, and grammY and Telegraf for JavaScript.
Code with an AI assistant
Telegram says plainly that its bot documentation is written with AI in mind too: if you have little coding experience, you can ask an AI assistant to read it and help you get started. Describe what the bot should do, ask for code on a specific library, and run it the same way as the example above. Two things stay with you: don’t paste the token into the chat with the assistant — let the code read it from an environment variable — and test the bot yourself before inviting people.
Step 4. Decide where the bot will run
While the program runs on your computer, the bot answers only while the computer is on. Telegram’s tutorial says so directly and suggests a server (a VPS) or a similar service for running all the time. If you chose a ready service, it takes care of this for you.
The program can receive messages in two ways, and they do not work at the same time:
- getUpdates (long polling). The program asks Telegram for new messages itself. That is how the example above works: any computer will do, no address on the internet is needed.
- A webhook. Telegram sends every message to your HTTPS address, on port 443, 80, 88 or 8443. You need it when the code runs in a cloud that starts on demand.
While a webhook is set, getUpdates does not work. Messages the bot has not picked up yet are kept by Telegram for up to 24 hours.
Step 5. Invite the first people
A bot cannot write to a person first: the person has to open the bot and press Start, or add it to a group. So share the link t.me/your_bot_username; people can also find the bot by its username in Telegram search.
Sending limits worth knowing in advance (from Telegram’s Bots FAQ):
- in a single chat — no more than about one message per second;
- in a group — no more than 20 messages per minute;
- in a broadcast — about 30 messages per second. Faster is possible only with paid broadcasts: up to 1,000 messages per second, at 0.1 Stars for each message over the free 30 per second. They can be enabled once the bot has at least 100,000 Stars on its balance and at least 100,000 monthly active users.
A bot in a group or a channel
- A group. Add the bot as a member. By default it runs in privacy mode: it sees commands meant for it, replies to its own messages and service messages, but not the whole conversation. A bot that is an admin sees all messages, and the mode can be turned off with
/setprivacy— after that the bot has to be re-added to the group. More in how to add a bot to a group. - A channel. A bot can post in a channel only if it is one of the channel’s administrators with the right to post messages.
For the bot to write to the right chat, it needs the chat ID. Every kind of chat is covered in the chat ID guide.
Why the bot is not responding
- The program is not running, or it crashed. Telegram itself does not answer for the bot.
- A webhook is set while the code reads getUpdates — or the other way round.
- Two copies of the program run with the same token and get in each other’s way picking up updates.
- In a group the bot does not see messages — that is privacy mode, see above.
- The bot cannot write to a person — they have not pressed Start yet, or they blocked the bot.
- The token was replaced in BotFather: the old one stopped working and the program gets Unauthorized. Put in the new one.
What it costs
Registering a bot with @BotFather and sending messages within the normal limits is free. The money goes to whatever runs behind the bot: a server for your own code, or a service’s plan. Stars are charged for paid broadcasts — they are needed to send more than about 30 messages per second and are open only to large bots.
Sources, checked October 2026: Telegram Bots — how bots work, a bot does not start a conversation first; Bot features — BotFather (/newbot, username rules, profile, editing commands, the BotFather Mini App), Privacy Mode, Managed Bots, the documentation for AI; Bots FAQ — what a bot sees, long polling and webhooks, limits and paid broadcasts; Telegram Bot API — getUpdates and setWebhook (ports, updates kept for 24 hours), setMyDescription and setMyShortDescription; Bot tutorial — the token out of the code, hosting; Bot API Library Examples — libraries for the Bot API.
What people usually ask
- Can I create a Telegram bot for free?
- Registering a bot with @BotFather costs nothing, and so does ordinary sending through the Bot API. What you pay for is whatever runs behind the bot: your own server if you write code, or a service that runs the bot for you. Sending faster than about 30 messages per second takes paid broadcasts, which cost Stars and are open only to large bots.
- Can I create a Telegram bot on my phone?
- Yes. @BotFather is an ordinary chat, and /newbot, /mybots and the other commands work in the mobile app exactly as on a computer; BotFather also has a Mini App with buttons instead of commands. The only thing a phone is awkward for is running your own code, which needs a computer or a server.
- Do I need to know how to code to make a bot?
- Not to register one: that is a few messages to @BotFather. For the bot to do anything, a program has to answer for it: you can write it yourself, ask an AI assistant to write it, or connect the bot to a ready service where the job is already built.
- Why is my bot not responding?
- Most often because the bot's program is not running: Telegram only delivers messages, your code or service is what answers. It also happens that a webhook is set for the bot while the code reads updates with getUpdates, and the two do not work at the same time. In a group where it is not an admin, a bot by default sees only commands meant for it, replies to it and service messages.
- Can I change my bot's username?
- No. The name can be changed with /setname at any time, but the username ending in bot cannot be changed after creation (a collectible username bought on Fragment can be added on top). If it does not fit, create a new bot; the old one can be deleted with /deletebot, which frees its username, but a deleted bot cannot be brought back.
- How do I make an AI chatbot on Telegram?
- Create the bot in @BotFather and connect it to a program or service that passes questions to a language model and sends the answers back. You can write that program yourself, and Telegram itself suggests reading its documentation together with an AI assistant, or connect the bot to a service with AI answers built in.