Skip to content
Related Articles

Related Articles

Node.js Bot.start() Method
  • Last Updated : 09 Dec, 2020
GeeksforGeeks - Summer Carnival Banner

The Bot.start() method is used in the Node.js Telegraf Bot Module. This module provides various functions to interact with the official Telegram Bot API. This method executes when a new user first time starts the bot or type reserved module keyword /start.


TelegrafBot.start(callback function(Context function))

Parameters: This Method accepts one parameter as mentioned above and described below: 

  • Callback function: It accepts only one parameter that holds the Update object from Telegram API.

Return Type: The return type of the function is void. 

Installing Module: Install this module using the following command: 

npm install telegraf

Steps to get the keys: 

1. First, get the GET BOT_TOKEN from BOTFATHER in the telegram. Just search for BOTFATHER in Telegram and select the verified one as shown below: 

2. Type /start and then click on /newbot as shown below: 

3. Now type the name of the bot and that must be unique. 

4. Now just copy the token From the BotFather. And for deleting the token simply search /delete token in BotFather.

Project Structure:  

Filename: bot.js 


// Requiring module 
const telegraf = require("telegraf"); 
// Set your token 
var token = 'YOUR_TOKEN'
// Creating a new object of Telegraf 
const bot = new telegraf(token); 
// The ctx object holds the update 
// object from Telegram API
bot.start( ctx => {
  // Sending the message
  ctx.reply("Thanking you for chossing new bot"); 
// Calling the launch function 

Run the bot.js file using the following command:

node bot.js


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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :