By the end of this lesson you will know what a Telegram bot can and cannot do, have a one-page plan for your bot, and have created the bot in @BotFather with its token kept safe.
You need: Telegram on your phone or laptop, and a coding agent or a notes app for the plan · Time: 8 minutes
A Telegram bot is a Telegram account that is run by your code instead of a person. Customers chat with it like with a shop on WhatsApp: they type a command or tap a button, and your code decides the reply.
Our example for the whole course is Sharma Tiffin Service in Indore. About 60 students and office workers order lunch for the next day. Today they call or WhatsApp Mrs. Sharma, and she writes every order in a notebook until 9 PM. The bot will:
- show the menu and answer common questions (timings, delivery area, payment),
- take tomorrow's lunch order with buttons,
- send a daily reminder, but only to customers who said yes,
- send every new order to Mrs. Sharma's own Telegram.
Running a college club instead? The same pieces make a club bot:
/eventsinstead of/menu, an RSVP button instead of an order, and a reminder the day before each event.Every message travels customer → Telegram → your code, and the reply goes back the same way. Why?When something goes wrong later, these three boxes tell you where to look: the customer's phone, Telegram, or your code. Most problems are in box 3, and that is the box you control.
A bot can reply to messages and commands, show buttons, send photos and files, remember orders in a database, and send messages at any time to people who have already started it.
A bot cannot do these, and it helps to know before you plan:
- Message someone first. Telegram's docs say bots can't start conversations: a user must add the bot to a group or send it a message first. So you cannot load your notebook's phone numbers and message everyone. Customers join through your link (
t.me/YourBotName) or a QR code at the counter. - Read every message in a group. In groups, bots run in privacy mode by default: they only see commands meant for them, replies to their own messages and a few other cases. Bots that are group admins see all messages.
- Work while your code is off. Telegram keeps waiting messages for up to 24 hours, but nobody answers them until your code runs again (lesson 4 fixes this).
- Send unlimited messages. Telegram limits how fast a bot can send (lesson 3), and customers can block a bot that spams them.
Match them Match each situation with what really happens
Tap an item on the left, then its meaning on the right.
Why?Many beginner plans fail on these limits, for example "the bot will send offers to all my contacts". Knowing them now keeps your plan realistic and keeps your bot from looking like spam.
- Message someone first. Telegram's docs say bots can't start conversations: a user must add the bot to a group or send it a message first. So you cannot load your notebook's phone numbers and message everyone. Customers join through your link (
A command is a word starting with
/that the user taps or types, like/menu. Telegram allows up to 32 characters: Latin letters, numbers and underscores. Keep them short and obvious:/start: welcome message and what the bot can do (Telegram shows a Start button the first time)/menu: tomorrow's menu with prices/order: order tomorrow's lunch with buttons/help: answers to common questions and a phone number/stop: stop the daily reminder
Before any code, let your agent turn this into a one-page plan. Use the Prompt Card and change only the parts in [square brackets]:
Prompt · copy it into your AI agentGoal: Write a one-page plan (PLAN.md) for a Telegram bot for my tiffin business. No code yet. Context: I run [Sharma Tiffin Service] in [Indore]. About [60] regular customers (students and office staff) order lunch for the next day. Today they call or WhatsApp me and I write the orders in a notebook. I cannot code; later you will build the bot in Node.js with the grammY library. Details: - Commands: /start (welcome and what the bot does), /menu (tomorrow's menu with prices), /order (order tomorrow's lunch with buttons), /help (common questions and my phone number), /stop (stop daily reminders). - Order steps: item, quantity, time slot ([12:30 to 1:00] or [1:00 to 1:30]), then a Confirm button. - Every new order is sent to my own Telegram. - A daily reminder at [11:00 AM India time], only to customers who said yes to reminders. - Answers to common questions come from a text file I can edit: timings, delivery area, payment by UPI on delivery. Rules: - Write only PLAN.md, in plain English, no code. - For each command: what the customer sends, what the bot replies, and what is saved. - Add a section "What the bot will NOT do": no payments inside the bot, no messages to people who never started it. - End with a list of open questions you need me to answer. Done when: PLAN.md fits on one screen, I can read every reply out loud and it makes sense to me, and the open questions are listed at the end.
Why?A written plan stops the agent from inventing features you never asked for. It also becomes your checklist: in every later lesson you test the bot against PLAN.md.
@BotFather is Telegram's official bot for creating and managing bots. In Telegram:
- Search for
@BotFatherand open it. Check the name carefully: copies with similar names exist, and the official one has a verified tick. - Tap Start, then send
/newbot. - Send the name: what people see in chats and contact details. It can have spaces, for example
Sharma Tiffin Service. You can change it later. - Send the username: the unique address used in search and links. It must be 5 to 32 characters, use only Latin letters, numbers and underscores, and end in
bot, for exampleSharmaTiffinBotorsharma_tiffin_bot. If it is taken, try another. - BotFather replies with a link to your bot and the token. Do not copy the token anywhere yet; lesson 2 shows the one safe place for it.
BotFather also has a Mini App, a newer screen inside Telegram with the same features. Either way works. This course uses the chat commands because they are easier to describe step by step.
A simplified mock of the BotFather chat. The real wording can differ slightly. Do it now Do it now
Why?The bot does not reply yet because no code is running (box 3 in the picture is empty). Creating it now gives you the username for your plan and the token for lesson 2.
- Search for
The token is a long string of numbers and letters that lets code act as your bot. Telegram's docs put it plainly: everyone who has your token has full control over your bot. Think of it like the UPI PIN of your bot: someone with it can read your customers' messages and send anything in your bot's name.
So the token goes only into a
.envfile on your computer and into your host's secret settings later. Never:- in the code itself or in Git and GitHub,
- in a screenshot, a screen recording or a YouTube video,
- in a WhatsApp group, an email or a chat with an AI. Your agent only needs the name of the setting,
BOT_TOKEN, never the value.
If it leaks, replace it at once: in @BotFather send
/mybots, choose your bot, open API Token and revoke the current token. Telegram's guide also lists the/tokencommand for getting a new one. The old token stops working, and you put the new one in.env. The full leak routine is in Keep secrets secret.CarefulDeleting the message or screenshot that showed the token is not enough. Someone may already have copied it. Only replacing the token in @BotFather makes the old one useless.
- A bot is a Telegram account run by your code: customer → Telegram → your code and back.
- A bot cannot message people first, sees little in groups (privacy mode), and only answers while your code runs.
- Plan the commands (
/start,/menu,/order,/help,/stop) in a one-page PLAN.md before any code. - Create the bot with
/newbotin @BotFather; the username must end inbot. - The token is a password: only in
.env, and revoke it in @BotFather if it leaks. - Next: Run your first bot on your laptop.
Create a free account to save your progress and open every lesson. Create free account