No history yet

Introduction to Telegram Bots

What Are Telegram Bots?

Telegram bots are small programs that run inside the Telegram app. Think of them as automated assistants you can chat with. They don't have their own phone number or online status, but they have a unique username that ends in "bot".

What can they do? Almost anything. A bot can send you news updates, weather forecasts, or reminders. It can integrate with other services, like YouTube or GitHub, to fetch information or perform actions. Some bots offer games, while others can help you manage your group chats. They are powerful tools for automating tasks and creating interactive experiences directly within your messaging app.

Lesson image

Meet the BotFather

To create a bot, you don't need to write any code right away. Instead, you talk to another bot. Telegram has an official bot for managing all other bots, and its name is BotFather.

BotFather is the official bot provided by Telegram to help you create and manage your bots.

You'll use BotFather for everything from creating a new bot to deleting one, changing its name, or generating the authorization keys it needs to function. It's your central command center for bot management.

Creating Your First Bot

Let's walk through the steps to register your very own bot. It's a simple conversation with BotFather.

  1. Find BotFather. Open Telegram, go to the search bar, and type @BotFather. Look for the official account with a blue checkmark next to its name. Start a chat with it.

  2. Start the process. Send the command /newbot. BotFather will immediately reply, asking for a name for your bot.

  3. Choose a name. This is the display name your users will see in their contact list and at the top of the chat. It can be anything you like. For example, you could type My Test Bot.

  4. Choose a username. Next, BotFather will ask for a username. This must be unique and must end in bot. For instance, MyTestBot or my_test_bot are valid usernames. If the name is taken, you'll have to try another one.

A bot's username is its unique identifier. It must be between 5 and 32 characters long and end with the word "bot".

Once you provide a valid username, BotFather will congratulate you and send a confirmation message. This message contains a very important piece of information: your bot token.

The All-Important Bot Token

The bot token is a long string of numbers and letters that acts as a secret key. It's what you'll use in your code to authorize your bot and send requests to the Telegram API. Essentially, it proves to Telegram that you are the bot's rightful owner.

Treat your token like a password. Anyone who has it can control your bot. Never share it publicly or commit it to a public code repository.

The message from BotFather will look something like this:

Done! Congratulations on your new bot... Use this token to access the HTTP API: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11

Copy this token and save it somewhere safe. If you ever lose it or think it's been compromised, you can use BotFather to generate a new one with the /token command.

Now that you have your token, you have everything you need to start bringing your bot to life.

Quiz Questions 1/5

What is the name of the official bot used to create and manage other Telegram bots?

Quiz Questions 2/5

When creating a new bot, what is the first command you should send to BotFather?