A
A
Alexander2021-11-04 15:37:30
JavaScript
Alexander, 2021-11-04 15:37:30

How to implement keyboard navigation in telegraf?

Please tell me how to implement keyboard navigation in telegraf using Markup.keyboard?
Now I don’t understand how to implement the back button in the form of dynamics so that the bot understands which menu it is in and returns one nesting back
I will be grateful for the answer

bot.command('start', async (ctx) => {
    return await ctx.reply(
      'Custom buttons keyboard',
      Markup.keyboard([
        [' Search', ' Popular'],
        ['☸ Setting', ' Feedback'],
        [' Ads', '⭐️ Rate us', ' Share'],
      ])
        .oneTime()
        .resize()
    )
  })

  bot.hears(' Search', (ctx) =>
    ctx.reply(
      ' Search',
      Markup.keyboard()
        .oneTime()
        .resize()
    )
  )
  bot.hears('Search Param 1', (ctx) =>
    ctx.reply(
      'Search Param 1',
      Markup.keyboard()
        .oneTime()
        .resize()
    )
  )
bot.hears(' Back', (ctx) => ctx.reply('Back'))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question