0

Friends. Tell me, please: how to display both buttons and {parse_mode: 'HTML'} through node-telegram-bot-api on Node JS?

bot.sendMessage(chatId, `${msg.from.first_name}, <b>Hello!</b> ✌ `, {parse_mode: 'HTML', menuOptions})

But the telegram bot gives out only bold text, without buttons.

Swapped parse_mode: 'HTML' and menuOptions. I put menuOptions after the curly braces - the result did not change. I couldn't find the info I needed on google.

kh0dan
  • 1

1 Answers1

0

With inline keyboard:

  bot.sendMessage(msg.chat.id, "<b>bold</b> <i>italic</i>", {
    parse_mode: "HTML",
    reply_markup: {
      inline_keyboard: [
        [
          {
            text: 'Google',
            url: 'https://google.com'
          }
        ]
      ]
    }
  })

With normal keyboard:

  bot.sendMessage(msg.chat.id, "<b>bold</b> <i>italic</i>", {
    parse_mode: "HTML",
    reply_markup: {
      keyboard: [
        ['A'],
        ['B']
      ]
    }
  })
Mohamed Sohail
  • 1,659
  • 12
  • 23
  • And if I have buttons in a separate file, can I display them in this message with the "menuOptions" variable or not? – kh0dan Nov 23 '22 at 16:12
  • Yes you can, it just has to follow the same JSON format above. – Mohamed Sohail Nov 24 '22 at 06:07
  • It matches. But when I do: `bot.sendMessage(msg.chat.id, "bold italic", { parse_mode: "HTML", reOptions})` it doesn't work. Code reOptions: `reOptions: { reply_markup: JSON.stringify({ inline_keyboard: [ [{text: 'Назад', callback_data: '/re'}] ] }) },` – kh0dan Nov 24 '22 at 15:23