Open In App
Related Articles

Node.js Bot.sendVideo() Method

Improve Article
Save Article
Like Article

The Bot.sendVideo() 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 send Videos having different formats.


TelegramBot.sendVideo(chatId, location)

Parameters: This Method accepts two parameters as mentioned above and described below:

  • chatId: A chatId is a unique identifier for a chat, that can be either private, group, supergroup or channel whereas userId is a unique identifier for a user or bot only. Every Client’s Message contains chatId.
  • Location: Location of the video which we want to send in String format.

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:

  1. First, get the GET BOT_TOKEN from BOTFATHER in 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

var token = 'Enter the token';
const TelegramBot = require('node-telegram-bot-api');
const bot = new TelegramBot(token, {polling: true});
// Matches "/echo [whatever]"
bot.onText(/\/echo(.+)/, (msg, match) => {
  // The 'msg' is the received Message from Telegram
  // and 'match' is the result of executing the regexp 
  // above on the text content of the message
  const chatId =;
  // The captured "whatever"
  const resp = match[1]; 
  // Reply the message
  bot.sendMessage(chatId, "Your Video is");  
  // Sending the video to the Telegram Bot
  bot.sendVideo(chatId, "h.mp3");  

Run bot.js file using the following command:

node bot.js


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 01 Oct, 2020
Like Article
Save Article
Similar Reads
Related Tutorials