Telegram Bot
Telegram
Telegram is a cloud-based instant messaging and voice over IP services developed by Telegram messenger, a company registered in London, United Kingdom.
The telegram client application is available for Android, iOS, Windows Phone, and Desktop. We can send messages and transfer Photos, Videos, Audio, and Documents. We can create groups up to 200,000 people or channels for broadcasting to unlimited audiences. Telegram supports end-to-end encrypted voice calls. In addition to that Telegram allows users to create their Bots and can embed it in telegram chats or channels to perform specific functions.
What is a Bot?
The bot is one which can simplify the interaction between the user and a machine. It helps us by making us not to leave our current application unnecessarily to search for an online source. Users can interact with a bot by sending them messages, commands, and inline requests. We can develop bots and make them run in a Telegram application.
How to build a Telegram Bot?
The first thing the user needs to create a bot is to register on Telegram. We can either use Telegram web or Telegram mobile for the development.
Once we register with the Telegram application open the application and search for the @BotFather and start to chat with the bot.
BotFather is the one bot to rule them all. Use it to create new bot accounts and to manage the existing bots
Send /newbot message or a command to BotFather and follow the instruction
Once complete the instruction user will be getting a TOKEN and a Username which is set by the user to access the Telegram API. The user can https://telegram.me/USERNAME. And the TOKEN will look like “762289039:AAGPLv2wq***********************”
- Getting Started
We can use programming languages such as Python, Java, Node JS, etc to build the Bot.
Before we start writing a program we need to install the required libraries/ dependencies for the development.
2. Install the library
Since we are going to use the Telebot library for the bot development we need to install the telebot library in our system. It can be installed using the following command.
3. Hello World
Import the libraries for the development and start coding.
4. Run the Code
Now we can run the python code in the console and we can test in the telegram(https://telegram.me/USERNAME).
Once the program starts running we can start a chat with the bot.
This is the way to start building a telegram bot using Python 3 and Telebot library with the help of BotFather.
Examples of Telegram Bots
Following are some of the Telegram bots which are developed by using the above ideas.