2

I use example from documentation:

bot.command('inline', (ctx) => {
    return ctx.reply('<b>Coke</b> or <i>Pepsi?</i>', {
        parse_mode: 'HTML',
        ...Markup.inlineKeyboard([
            Markup.button.callback('Coke', 'Coke'),
            Markup.button.callback('Pepsi', 'Pepsi')
        ])
    })
});

bot.action(/.+/, (ctx) => {
    return ctx.answerCbQuery(`Oh, ${ctx.match[0]}! Great choice`)
});

On /inline command, i see the message "Coke or Pepsi?" with two buttons "Coke" and "Pepsi" but if I click on one of them, nothing is happens.

1 Answers1

1
    const {Telegraf} = require("telegraf")
    const { Keyboard } = require('telegram-keyboard')
    require('dotenv').config()
    const bot = new Telegraf(process.env.BOT_TOKEN)


    bot.hears(["Hi","hi","hello"],async (ctx)=>{
        const keyboard = Keyboard.make([
            ['Button One',{text:"Button Two 
    Text",callback_data:"callbacktextoranytext"], // First row
          ])
        await ctx.replyWithHTML('This a simple text', keyboard.inline())
})


bot.on("callback_query",(ctx)=>{
    console.log(ctx.callbackQuery.data)
    ctx.reply(ctx.callbackQuery.data)//here you can handle callback text
})

bot.launch()

I am using telegram-keyboard package here

Vatsal
  • 36
  • 4