Skip to content
Related Articles

Related Articles

Node.js Bot.help() Method
  • Last Updated : 16 Feb, 2021

The Bot.help() 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 we type reserved keyword /help. This method generally used when we have any query related to the bot functioning and return output related to your query. 

Syntax: 

TelegrafBot.help(callback)

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

  • Callback function: This method 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 the module using the following command: 



npm install telegraf

Steps to get the keys: 

  • 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: 

  • 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.

Project Structure:  

Filename: bot.js 

Javascript

filter_none

edit
close

play_arrow

link
brightness_4
code

// Requiring module
const telegraf = require("telegraf");
  
// Set your token 
var token = 'YOUR_TOKEN';
  
// Creating a new object of Telegraf
const bot = new telegraf(token);
  
bot.help(ctx => {
  
    // The ctx object holds the Update
    // object from Telegram API
    ctx.reply("Yes what can i help");
  
    bot.hears("What is your name", ctx => {
          
        // Reply with your custom message
        ctx.reply("Hi This bot Created by Zack_aayush")
    })
})
  
// Calling the launch function
bot.launch()

chevron_right


Run the bot.js file using the following command:

node bot.js

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :