August 16, 2022

How to create bot in Telegram

One of the distinguishing features of Telegram is bots. Everyone can create a programmatically controlled special user in Telegram called a bot and Telegram provides an excellent documentation on how to program it - https://core.telegram.org/bots/api

In this article, you’ll learn how to register your bot with Telegram. There are 3 different ways to make it do what you need once registered:

The first two approaches allow you to customize bot behavior. But they might be costly to implement.

In most cases, bot’s functionalities fall into certain categories, so developers created platforms to host them. For example, on bothelp.io you can set up your bot as a drip marketing campaign. And on telegr.store your bot will serve as an online store selling goods.

Start a dialog with BotFather

BotFather is a special official (provided by Telegram team, hence the checkmark next to its name) bot which create new bots.

Search for BotFather in the search bar and click on it (the one with a blue checkmark).

Create a bot

In the lower left side of the window, select a menu button and click on /newbot command.

BotFather will ask for a name - send a message with a name of your bot. You can change it later anytime.

Now the username, which can be the same as a name and must end with “bot”. This cannot be changed later on and will be a part of URL, you’ll share with bot’s users.

After you send the username, BotFather will reply with registration confirmation. It contains a very important piece of information - bot’s token. Save it somewhere safe. You’ll need it later to integrate your DIY or platform-controlled bot.

Customize your bot

Once the bot is registered, you may customize its avatar and description.

Click in the menu button in the lower-left corner of the Telegram client and select /mybots command. It will display all the bots you’ve created.

Now click on the one you need to customize - you’ll be presented with a number of buttons. Click in “Edit Bot”. Here you can edit bot’s name, description, about info and avatars.

  • About is a short text that will appear under bot’s URL when you share it on social media.

  • Description is a somewhat longer text about your bot users will see when they first open your bot. Description Picture is a picture you place above the description.

And name is just a name users will see in the chat list

Set up commands

Just like BotFather has a menu with all the command it understands, your bot may have such a list as well.

In the same “Edit bot” menu, select “Edit commands”. In case of DIY bot, you need to set it up, so your users know what to expect from it. But if your bot is hosted, for example, on telegr.store, the platform itself will set the commands for you.

Bot behavior in groups, channels and chats

Since everyone may access your bot, you may want to set how it works when it’s invoked from chats, groups and channels.

Inline mode

If you have a chat with a real person, you may use @gif bot to search for an animated image. This GIF bot works inline - a mode you can enable for your bot.

Bot as a group member

You may allow your bot to participate in groups or even become the group’s admin. When the bot is added as an admin, it may acquire a set of rights you set up in advance.

Group bot have a privacy option - it means that a bot won’t be able to read all the messages in the group chat, but only commands starting with /, or replies to its own messages.

Bot as a channel subscriber

Bots can subscribe to channels. You set up the rights your bot will require when added to a channel.

All these settings are available from the main bot menu

Payments

Your bot can accept payments from users. Stay tuned to learn more about this innovative feature.


Start your own Telegram store bot at telegr.store



© Alex Smirnov 2022