Tutorial
How to create a Telegram bot in 2026, with AI and without code
To create a Telegram bot, open a chat with @BotFather, send /newbot, choose a display name and a username that ends in "bot", and copy the token BotFather sends back. That token lets software act as your bot: connect it to your own code, or to an AI agent platform that reads and answers messages for you, and the bot is live. This tutorial covers both routes, plus what makes a bot worth talking to.
In this guide
- Create the bot with BotFather
- Code or no code
- A minimal bot in Python
- An AI Telegram bot without code
- Making the bot useful
- Earning money from a Telegram bot
- Security
- Common mistakes
How do you create a Telegram bot with BotFather?
Every Telegram bot is created through @BotFather, Telegram's own bot for making and managing bots. The steps below follow Telegram's BotFather tutorial and bot features page, checked 16 October 2026.
- Open @BotFather. Search for it in Telegram or open t.me/BotFather, check the username is exactly @BotFather, and tap Start.
- Send /newbot. BotFather asks two questions.
- Choose a name. The display name people see in chats. You can change it later.
- Choose a username. 5 to 32 characters, ending in "bot", for example acme_support_bot. Unlike the name, it cannot be changed later.
- Copy the token. BotFather replies with the bot's API token. Anyone who has it controls your bot, so keep it out of chats, screenshots and code repositories.
Give the bot a profile
- /setdescription: the text people see in an empty chat before they press Start (up to 512 characters in the Bot API).
- /setabouttext: the short text on the bot's profile page (the Bot API's short description, up to 120 characters).
- /setuserpic: the bot's picture.
- /setcommands: the command list Telegram suggests when someone types "/".
- /setprivacy: what the bot can read in groups (see security).
BotFather's command list changes over time; typing / in its chat shows the current set.
Code or no code: which route should you take?
Write code if the bot does one fixed job, such as posting alerts or answering a few commands. Use an AI agent platform if it should understand free-form messages, remember people and act in your other tools.
| Your own code | AI agent platform (no code) | |
|---|---|---|
| What you build | Every handler and reply | An agent: instructions, knowledge, tools |
| Hosting | A server or function you keep running | Run for you, or self-hosted |
| Free-text messages | Only what you program, or a model API you wire in | A language model reads every message |
| Memory | Storage you design | Built in, per person on a public bot |
| Tools and approvals | Each API integrated by hand | Connector catalogue and an approvals inbox |
| Payments | Invoices, refunds and records you implement | A Stars or Stripe paywall with a free trial |
| Best for | Fixed commands, alerts, games, full control | Assistants, support desks, paid AI bots |
How do you build a Telegram bot in Python?
The shortest route is the python-telegram-bot library: install it, read the token from an environment variable, add handlers and start polling. The example below was checked against python-telegram-bot 22.8 (released June 2026, Bot API 10.0, Python 3.10 or newer).
pip install python-telegram-bot
import os
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text("Hello. Send me any message and I will repeat it.")
async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(update.message.text)
def main() -> None:
app = Application.builder().token(os.environ["TELEGRAM_BOT_TOKEN"]).build()
app.add_handler(CommandHandler("start", start))
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))
app.run_polling(allowed_updates=Update.ALL_TYPES)
if __name__ == "__main__":
main()
Run it with TELEGRAM_BOT_TOKEN=your-token python bot.py and message the bot. It only repeats what it is sent; making it useful means calling a model for replies, storing each person's history, staying inside Telegram's rate limits and keeping the process running, which is most of the work.
Long polling or webhooks?
Your code receives messages one of two ways. Long polling (getUpdates) asks Telegram for new updates and works from a laptop with no public address, which is why the example uses it. A webhook (setWebhook) has Telegram push each update to an HTTPS URL you own, on port 443, 80, 88 or 8443, optionally with a secret token header so your server can reject requests Telegram did not send. They are exclusive: you cannot receive updates with getUpdates while a webhook is set (Telegram's webhook guide).
What rate limits does Telegram set?
Telegram's Bots FAQ asks bots to avoid more than one message per second in a single chat, allows no more than 20 messages per minute in a group, and caps bulk notifications at about 30 messages per second unless paid broadcasts are enabled, which raise it to 1,000 per second at a cost in Stars. Go over and Telegram answers with 429 errors.
How do you make an AI Telegram bot without code?
Give the BotFather token to an AI agent instead of to your own code. On Olano that is a connector: the agent reads every message, answers in its own words, remembers the person and can act in your other tools, with nothing to program or host.
- Create the agent. Name it, pick a model and say what it is for, or start from one of 180+ specialist agents in the catalogue.
- Add the Telegram connector. Open the agent's Connectors tab, add Telegram and paste the token; it is stored in the encrypted vault, not in the agent's configuration. Or ask the agent to connect Telegram: it sends a magic link where you paste the token, so it never passes through the conversation.
- Decide who may talk to it. On Telegram, Allowed users is a hard gate: list numeric user IDs or @usernames and nobody else gets in. For a private assistant, list yourself. For a public bot, leave it empty and put yourself under Owner users.
- Restart the agent. Channel credentials are read at start-up, and a freshly connected bot that never replies has usually not been restarted.
- Message the bot. One token per agent: two agents sharing a token conflict, and one of them stops receiving messages.
The Notion + Telegram tutorial shows this loop end to end in five minutes, and the Salesforce + Telegram tutorial runs it against a CRM. To see the result first, message @OlanoAIBot, our own agent on Telegram.
What makes a Telegram bot actually useful?
Three things separate a useful bot from an echo: it remembers, it can act, and it knows when to ask a person first.
Memory and knowledge
An Olano agent keeps readable Markdown memory and a knowledge base of your documents, so answers come from your own material. On a public bot, multi-user mode gives each person isolated memory keyed to their Telegram identity, erasable on request, so one user's details never surface in another's chat (multi-user agents).
Tools
450+ connector tools and a library of 200+ MCP servers let the agent check a calendar, update a CRM or file a document from a Telegram message.
Approvals
You decide which actions run on their own and which wait for a person in the Approvals inbox; the riskiest keep waiting even in automatic modes. Start with reads automatic and anything that writes or sends gated.
Guardrails for a public bot
Message policy caps bound what strangers can cost you: a maximum message length, spam patterns dropped before any model call, plain-language rules for what to ignore, and a ceiling on reply length. Slash commands are never screened, so you cannot lock yourself out. Set the chat to quiet so customers see answers, not the agent's working.
How can you earn money from a Telegram bot?
Charge for access in Telegram Stars. Telegram's payments documentation requires bots that sell digital goods or services to take payment in Stars; physical goods can use a third-party payment provider through the Bot Payments API. Checked 16 October 2026:
- Users buy Stars through Apple or Google in-app purchase or @PremiumBot, then pay inside the chat.
- Stars subscriptions renew every 30 days, at up to 10,000 Stars a period.
- A selling bot must answer /paysupport and handle disputes (Bot Platform Developer Terms); refunds come out of your Stars balance.
- Earnings can be withdrawn through Fragment 21 days after they are earned, or spent on Telegram Ads. Telegram sets a Star's value at withdrawal, so check the current rate before pricing.
On Olano, the agent's Monetization tab takes a Stars amount and a free trial (3 days by default). The check runs before the model does, and owners and allow-listed users are never charged. How to monetize an AI agent works through the numbers.
How do you keep a Telegram bot secure?
Protect the token, limit who can talk to the bot, and know what it can see in groups.
- The token. Whoever holds it controls the bot. If it leaks, revoke it through @BotFather, generate a new one and update everywhere the old one was stored. On Olano it is stored in the encrypted vault, and an agent asks for it by magic link, never in the chat.
- Who can talk to it. A private bot should name its users. Prefer numeric IDs to @usernames, which their owners can change.
- Privacy mode. On by default: in groups, a bot sees commands meant for it and replies to its own messages, not the whole conversation, while admin bots receive every message. Turning it off with /setprivacy takes effect after you re-add the bot to the group.
- Group behaviour on Olano. Group replies can be all messages, @mentions only or never, and group listening, which keeps unanswered group messages in the agent's history, is off by default.
Common mistakes
- Posting the token in a screenshot, a support thread or a public repository.
- Picking a username in a hurry. The name can change; the username cannot.
- Running two programs on one token, or leaving a webhook set while you test with polling.
- Expecting group chatter with privacy mode on. The bot sees only what is addressed to it.
- Skipping the restart after connecting the bot to an agent.
- A public AI bot with no caps on message or reply length.
- Selling a digital service by card inside the bot. Telegram's rules call for Stars.
How Olano helps
Olano turns a BotFather token into an AI agent with memory, 450+ connector tools, approvals, per-person isolation for public bots and a Stars or Stripe paywall, without code. The same agent can answer on WhatsApp, Slack and the rest of its 15+ messaging channels with one memory; channels and connectors covers each one. Olano can also attach an agent to your own Telegram Business account in secretary mode, off by default: it briefs you and drafts replies for your approval, or, if you allow it, answers directly with a human-paced delay.
The limits: BotFather still creates the bot, and the token stays yours; Olano Cloud is a paid platform (from US$25 a month, see pricing) plus model usage; and for a bot that only needs fixed commands, a few lines of code are cheaper than an agent. The full feature set is on the platform page.
FAQ
How can I create my bot?
Open @BotFather in Telegram, send /newbot, pick a name and a username ending in "bot", and copy the token it sends. Connect that token to your own code or to an AI agent platform, and the bot starts answering.
How do I message BotFather on Telegram?
Search for @BotFather in Telegram or open t.me/BotFather, check the username is exactly that, and tap Start. Then send commands such as /newbot; typing / shows its current command list.
How to earn money from a Telegram bot?
Charge for access or digital content in Telegram Stars, which Telegram requires for digital goods and services sold in bots. Stars subscriptions renew every 30 days, and earnings can be withdrawn through Fragment 21 days after they are earned.
Can I make an AI Telegram bot without coding?
Yes. Give the BotFather token to an AI agent platform instead of to code. On Olano you add the Telegram connector, paste the token, choose who may talk to the bot and restart the agent.
Why doesn't my bot see messages in a group?
Privacy mode is on by default, so in groups a bot sees only messages meant for it, such as commands and replies to it. Turn it off with /setprivacy in BotFather and re-add the bot, or make the bot a group admin.
What should I do if my bot token leaks?
Anyone with the token can control the bot. Revoke it through @BotFather, generate a new one, and update every place the old token was stored.
Related reading
Telegram agents built step by step, and what to do next.
Notion + Telegram in five minutes
Build an agent, connect Notion, add Telegram and use it from a phone.
Salesforce + Telegram
A CRM agent on your phone, with a three-tier approval boundary.
How to monetize an AI agent
Business models, a worked example and the Telegram Stars rules.
Channels and connectors
Every channel, allow-lists, credentials and group behaviour.
Multi-user agents
One public bot, separate memory for every person.
Olano pricing
Plans from US$25 a month, bring-your-own keys, no per-seat pricing.
Checked 16 October 2026 against Telegram's bot documentation (the BotFather tutorial, Bot features, the Bots FAQ, the Bot API reference, the webhook guide and the payments pages), the Bot Platform Developer Terms, and python-telegram-bot 22.8 on PyPI. Telegram changes BotFather and the Bot API regularly; its documentation is the primary source. Olano is not affiliated with Telegram. Spotted an error? Write to support@olano.ai.
Want an AI agent on Telegram?
Tell us what the bot should do and who will use it, and we will help you build the agent, its approvals and, if you charge for it, the paywall.