How to Create a Telegram Bot with Commands

How to Create a Telegram Bot with Commands

February 15, 2021 0 By Alex Balaniuc

Telegram is an instant messaging software that rose to fame in the last couple of years. Born as a competitor of WhatsApp, the app has been around since 2013 and it was launched by developers Nikolai and Pavel Durov. Telegram’s popularity took off as people started to realize that the app is one of the best on the market when it comes to secure messaging solutions, since it guarantees the users privacy thanks to its end-to-end encryption. Another reason as to why Telegram is being preferred over WhatsApp – the leading instant messaging app all around the world – is the recent controversy surrounding the latter’s new privacy policies; that is why Telegram is now estimated to have about 500 million active users.

What are Telegram bots?

Now, Telegram allows the use of bots, and if you don’t know what that means, we’ll explain it for you. Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and inline requests. But you can do so much more with a bot: it can provide you with translations, alerts, weather forecast, formatting, but it can also act as a newspaper that sends you newly published content or offer you paid services as a virtual storefront. Not to mention that bots allow you to share content from external apps and services, like YouTube, Gmail, GIF, etc.

Telegram bots are essentially special accounts that don’t require an additional phone number to set up. As a user, one of the ways to interact with bots is sending them messages and commands, so that you will start a chat with them, or you could also add them to chat groups.

Messages, commands and requests sent by the user are passed to the software running on your servers. The Telegram server acts as intermediary between you – the user – and the Bot server and it handles all encryption and communication with the Telegram API for you. You communicate with this server via a simple HTTPS-interface that offers a simplified version of the Telegram API. That interface is Telegram’s Bot API.

If you wish to create your own Telegram bot, you can do so by talking to BotFather, that will make you follow a few simple steps. And once you’ve created a bot and received your authorization token, you can teach your bot about what it can do.

But now, let’s dive right into the article and find out how to add commands to a bot!

Create a bot and add commands in a few easy steps

Once you created a bot, you can give it commands, meaning that the bot will perform certain actions or simply answer with a predefined message when prompted. Commands follow the syntax “/command“. They are used in many cases to communicate information to users without the need to send repetitive messages.

1) Create a bot

Before giving a bot commands, first you’ll need to create a bot by contacting the BotFather:

  • enter BotFather in Telegram’s search bar and select the first result

  • click the START button below to initiate a conversation with BotFather

  • now, you’ll be given a number of commands you can use on BotFather: click on “/newbot” to create a new bot


  • follow BotFather’s instructions. When you’re done, you’ll get a token code for controlling your bot

2) Add commands

You won’t need to have any programming skills for these next steps, because we’re simply going to use another bot that will allow us to create commands for our bot: Manybot. What you’ll need to do now is:

  • start a conversation with Manybot (enter its name in the search bar) and follow the instructions you’re given

  • Manybot will then ask you to send over a message your token code

  • done! Now you can access your bot and start giving it commands once you clicked on it (click on @nameofyourbot)

  • click on “Custom Commands”, and then on “Create Command”. Manybot will ask you to enter the name of your new command – for instance, “/best_photos”
  • now, what is your bot going to reply with?

  • save once you added a message\file to the reply, and just like that, your bot will now reply to the command (such as “/best_photos”) with the message\file you chose!