grammy inline buttons

 


const { InlineKeyboard  } = require('grammy')

bot.on('message', async (ctx) => {
    const keyboard = new InlineKeyboard()
      .row(
        { text: 'Button 1', callback_data: 'button_1' },
        { text: 'Button 2', callback_data: 'button_2' }
      )
      .row(
        { text: 'Button 3', callback_data: 'button_3' },
        { text: 'Button 4', callback_data: 'button_4' }
      );
    await ctx.reply('Please choose an option:', { reply_markup: keyboard });
  });

//answer callback query

bot.on('callback_query', async (ctx) => {
    const chatId = ctx.chat.id;
    const data = ctx.callbackQuery.data;
    await ctx.reply(`You chose option ${data}. ${ctx}`);
    await ctx.deleteMessage();
  });


Post a Comment

0 Comments