Well it’s not quite easy for a beginner to develop telegram bot in a short time by exploring the telegram bot API. I’ll just brief you the procedure by developing a basic telegram bot and I’m sure this tutorial would help you kick start with developing a telegram bot of your own with in a short time.
Once you get familiar with basic bot, you could explore the official telegram bot API for customizing your bot.
Let’s get started with developing a basic telegram bot.
1. Firstly, you would need to create or register your bot with Telegram. A Telegram’s bot called “BotFather” will help you do this.
Login into telegram either through web or app and search for “BotFather” in search box.
2. Select BotFather and you’ll find options to create a new bot in botfather chat.
3. Click on “/newbot” option and enter your bot’s name. I am naming my bot as “echo bot”.
4. Once you are done with creating your bot, you’ll be issued a token. Save this token for later use.
5. Now your bot is ready to show up on telegram, you may search your bot using it’s user name in search box.
6. Now that the bot is ready, let’s add some life to it. For this, we’ll have to develop a server for our bot to help it handle the actions(echo user input in our case). To get our server communicated with this bot, we use the token(in step 3) issued by BotFather.
7. Let’s develop a script which upon sending an input from our bot echoes it back to bot. I am using nodejs as server side language, it can also be developed in python. Since, node has pretty good number of modules that would make it easy for developing server-side, I’m using it. Here, I’m using a node module called node-telegram-bot-api which has pre-defined packages required for telegram bot API.
Server code for bot with filename echobot.js:
8. Now that our server is ready, let’s run the server using the following command:
9. Try the echo bot in telegram by sending the messages.
That’s it, your bot is ready to talk to you now 🙂 Hope you are aware of customizing your own telegram bot now.
Happy coding 😉