1

How can I build a button to request a live location from the user through a Telegram Bot?

I am using node-telegram-bot-api package in this project. I have this bot that requests location from the users. So far I've managed to build a button that requests one-time location data from the users. Here's the working code:

bot.onText(/start/, (msg) => {
  const opts = {
    reply_markup: JSON.stringify({
      keyboard: [
        [{text: 'Share Location', request_location: true }],
      ],
      resize_keyboard: true,
      one_time_keyboard: true,
    }),
  };
  bot.sendMessage(msg.chat.id, 'Some message goes here', opts);
});

What I would like to achieve is a button that automatically requests users' live location, so that the users don't have to manually click the 'attach' button > Location > Share My Live Location for... instead of those steps, a user just clicks on a button from the custom keyboard, the share live location menu will popup.

Is this possible?

Hafiz Hanif
  • 361
  • 1
  • 3
  • 20

0 Answers0