0

i want to replay to user with a message when he clicks on the button, i tried many solution but so far nothing worked, i get the callback_query data after user clicks on the button but the bot is replaying to him im using telegraf js library



// Add the callback query event handler
bot.on('callback_query', async (ctx) => {
  const buttonPressed = ctx.callbackQuery.data;

  if (buttonPressed === 'button1') {
    ctx.answerCbQuery('You pressed Button 1!');
    // Perform actions specific to Button 1
  } else if (buttonPressed === 'button2') {
    ctx.answerCbQuery('You pressed Button 2!');
    // Perform actions specific to Button 2
  }
});

// Your existing code
if (Object.keys(buttonReplay).length > 0) {
  for (const button of buttonReplay.actionButtons) {
    const inlineKeyboard = Markup.inlineKeyboard([
      Markup.button.callback("button 1", "button1"),
      Markup.button.callback("button 2", "button2"),
      Markup.button.url("open url", "https://google.com"),
    ]);

    await bot.telegram.sendMessage(chatId, "hi", inlineKeyboard);
  }
}

0 Answers0