The Bot.onText() method is used in the Node.js Telegram Bot API. This Node.js module to interact with the official Telegram Bot API. This method is used to reply when the users interact with the Telegram BOT.
Parameters: This Method accepts two parameters as mentioned above and described below:
- regexp: It’s the regular expression, the message must contains /echo.
- callback: It is the callback function which is passed as parameter and called when the function call is executed.
Return Type: The return type of the function is void.
Installing Module: Install the module using the following command:
npm i telegram-bot-api
Steps to get the keys:
- First get the GET BOT_TOKEN from BOTFATHER in telegram. Just search for BOTFATHER in Telegram and select the verified one as shown below:
- Type /start and then click on /newbot as shown below:
- Now type the name of the bot and that must be unique.
- Now just copy the token From the BotFather. And for deleting the token simply search /delete token in BotFather.
Run bot.js file using the following command:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.