How to Create a Telegram Bot with Commands

How to Create a Telegram Bot with Commands

February 15, 2021 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!

Apps used for cloning other apps on smartphones
Apps used for cloning other apps on smartphones
We produce multiple on-line accounts so we will simply manage multiple tasks. An account where you’ll be able to celebrate together with your friends and therefore you become skilled and find work done. Many cloning apps currently support multiple accounts…

Communication on the web: interview with Andrea Parisi
Communication on the web: interview with Andrea Parisi
Digitizer, visionary, digital communicator and everything related to web communication. This is handled by Andrea Parisi, a Sicilian who found his passion on the web and where he bases his profession on the conscious use of communication platforms. Knowing how…

How to configure your account in Telegram?
How to configure your account in Telegram?
Telegram, like WhatsApp, is one of the most widely used messaging apps worldwide. Recently, this application has considerably increased its number of users, because the new rules for using WhatsApp are not to the liking of many people. Telegram since…

Upload PDF Files on Google Classroom from Mobile Device
Upload PDF Files on Google Classroom from Mobile Device
Google Classroom is a free web service offered by Google meant to simplify the lives of many teachers and students. In short, Classroom allows users to create, distribute and grade assignments and - more in general - to share files…

Recover your Deleted Pictures from iPhone without Backup for Free
Recover your Deleted Pictures from iPhone without Backup for Free
Having a backup on iTunes or iCloud of your photos, videos and other files from your iPhone is always the best idea if you don't want to risk losing the files. So, if your phone breaks down, starts malfunctioning or…

What you Need to Know when Signing up as a TikTok Ads Manager
What you Need to Know when Signing up as a TikTok Ads Manager
TikTok is a short-form, video-sharing app that allows users to create and share 15-second videos on any topic possible developed by Chinese company ByteDance and launched in 2016. Plus, it's one of the most influential, trendy and popular apps of…