How to deploy a Telegram Bot using Botfather and NodeJS?

March 07, 2021

What is a Bot?

A bot is a software application that is programmed to do certain tasks. Bots are automated, which means they run according to their instructions without a human user needing to start them up. Bots often imitate or replace a human user’s behavior. Typically they do repetitive tasks, and they can do them much faster than human.

Type of Bots?

1.Chatbots
2.Web crawlers
3.Social bots
4.Malicious bots

Creating a Bot with Botfather on Telegram

1.First you should have Telegram desktop app or you mobile app.
2.Go to Botfather and read the documentation.
3.Into your Telegram account with the before steps search to Botfather and you can set /help and view a lot of options.

Botfather

4.Select /newbot and give it a name and username.

BotNameUserName

5.Keep secure the token to access the HTTP API, in this case for example we will use this token in our script

Using NodeJS for the call and Bot logic

The script divided into two parts. The first is the request call, for this case I used the Axios module, and the second part is the bot logic used in the Telebot module.

About NodeJS

Node.js is a JavaScript runtime environment. This means that the environment includes everything you need to execute a program written in JavaScript.

About

Download

Code

Github

Steps

git clone https://github.com/danielitogomez/nodejs-project.git
cd $PWD/nodejs-project/web-check-bot
Add your token in https://github.com/danielitogomez/nodejs-project/blob/master/web-check-bot/bot.js#L4
./init.sh
node bot.js

Start a chat with your bot and ask /help or /status, depending of your code.

BotStatus