Answer the question
In order to leave comments, you need to log in
Telegram Bot node js - How to get user id?
In general, the task is this: I need to give the user his own ID in the message. How can this be implemented?
I am using node-telegram-bot-api. Tried like this:
var idforuser = bot.user_id;
bot.on('message', (msg) => {
if (msg.text.toLowerCase() === "мой айди"){
bot.sendMessage(msg.chat.id, "Это твой айди - " + idforuser, menu)
}
});
Answer the question
In order to leave comments, you need to log in
The user ID comes in the from object. See https://t.me/RequestCodeBot for the structure of requests to bots
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question