Questions tagged [node-telegram-bot-api]

Node.js Telegram Bot API Node.js module to interact with official Telegram Bot API.

Node.js module to interact with official Telegram Bot API. A bot token is required and can be obtained by talking to @botfather.

Install

npm install --save node-telegram-bot-api

Usage

const TelegramBot = require('node-telegram-bot-api');

// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN';

// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});

// Matches "/echo [whatever]"
bot.onText(/\/echo (.+)/, (msg, match) => {
  // 'msg' is the received Message from Telegram
  // 'match' is the result of executing the regexp above on the text content
  // of the message

  const chatId = msg.chat.id;
  const resp = match[1]; // the captured "whatever"

  // send back the matched "whatever" to the chat
  bot.sendMessage(chatId, resp);
});

// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
  const chatId = msg.chat.id;

  // send a message to the chat acknowledging receipt of their message
  bot.sendMessage(chatId, 'Received your message');
});
159 questions
2
votes
1 answer

Can a pinned message have inline buttons?

I have a bot that I am building in telegram. This bot posts a “pinned” message. I’m curious if a pinned message can have inline buttons.
2
votes
1 answer

How to enable HTML in sendPhoto?

const html = `something` bot.sendPhoto(chatId, picture, { caption: html, parse_mode: 'HTML' }) Its half working - tags doesnt appear in text but also doesnt do anything. What am i doing wrong?
vitland
  • 21
  • 1
2
votes
1 answer

Telegraf framework. how to Forward message to a given group, chat or channel with telegram.forwardMessage();?

The problem: I need to get messages from aprox 400 users to a telegram bot. the bot hears for specific tags in the message and routes the messages to a group channel or user defined by the tag that the bot hears. when the final destination replys…
2
votes
1 answer

Telegram Bot Live Location via node.js

How Can I send telegram bot live location? I'm using node-telegram-bot-api Module. Code: This Code just Send a Location await bot.sendLocation(msg.chat.id, 35.804819, 51.434070);
Saeed Heidarizarei
  • 8,406
  • 21
  • 60
  • 103
1
vote
0 answers

How to generate telegram links which will forward a file or msg from other channel to the user

I have seen some websites where I press a button then the browser asked a permission to open telegram app. When I give the permission then the app opens on a Telegram Bot. If I press start button then bot forwards a message. How do they do it?? Any…
1
vote
0 answers

node-telegram-bot-api callback_query fires multiply

i`m trying to make telegram bot and dont understand why it works so. I have three js files index, quiz_creation, question_creation here is content index.js const createQuiz = require('./quiz_creation'); bot.onText(/\/start/, (msg) => { const…
1
vote
0 answers

How do I log in to a telegram account via sms and also withdraw tdate or session via node.js?

How do I log in to a telegram account via sms and also withdraw tdate or session via node.js? I will be very grateful. It is necessary that when a user enters a code in my bot with telegram, then his account is logged in and also the tdata or…
1
vote
0 answers

How can I ask for multiple name inputs and place them all in the poll? (Telegram bot)

here is my code right now "my first time dealing with telegram bots its for a hackathon" bot.onText(/\/dare/, async msg => { const namePrompt = await bot.sendMessage(msg.chat.id, "Who would you like to dare", { reply_markup: { …
1
vote
1 answer

js telegram bot. How to listen messages from my private channels and redirect to my channel

Can you provide some info on how to access js telegram bot to all my messages (from private channels)? I use node telegram bot API and know how to redirect messages that the bot received directly but how can the bot listen to messages from my…
1
vote
1 answer

switching bot.on listeners for different modules

I'm creating the telegram bot, and I have question. In app.js const { admin } = require('./admin'); require('dotenv').config(); const token = process.env.token; const bot = new TelegramBot(token, { polling: true }); let chatId = []; async function…
Student
  • 11
  • 2
1
vote
2 answers

Telegram bot: editMessageReplyMarkup method doesn't work

I've developed a telegram bot using Node.js and node-telegram-bot-api module that sends a message and an inline keyboard to the users, what I'm trying is to achieve that after the user clicks the button, the inline keyboard must disappear. I'm using…
1
vote
0 answers

Speech to text wit.ai telegram bot

I'm making a telegram bot. Using node js (node-telegram-bot-api), axios, wit.ai. Voice to text not working. What i doing wrong?I need to translate a voice message into text, but my script does not work require('dotenv').config() const TelegramApi…
1
vote
1 answer

is it possible to install copy protection in a telegram bot?

is it possible to install copy protection in a telegram bot? the bot sends docx files, images and text. I would like to make it so that they cannot be copied but can be viewed. I couldn't find anything in the telegram bot api documentation, I can't…
1
vote
1 answer

Node telegram bot api - disable processing of updates sent before the bot starts

I, have this issue: when I start the bot it immediately starts looking for updates. However, in my particular case (especially during the developing) this can be very frustrating and uncomfortable. There is a way to tell the bot to process the…
1
vote
1 answer

chat_member not getting invocked

I am using TelegrafJS and nodejs for developing a telegram bot and I want to use "chat_member" because it returns the invite link used by the user to join the telegram group. but the problem is it is not getting invoked. when new members are joined.…
1 2
3
10 11