Search code examples
node.jstelegramtelegram-botnode-telegram-bot-api

Telegram bot Nested previous button,node.js


How Can I Back from 3th Level node to Secend level node after That to First Level node? My Problem is Back Name, Because That is Same,,, This is my Code:

    bot.onText(/\/start/, function onLoveText(msg) {
      const opts = {
        reply_to_message_id: msg.message_id,
        reply_markup: JSON.stringify({
          keyboard: StartKeyboard,
          resize_keyboard:true,
          one_time_keyboard: true
        })
      };
      bot.sendMessage(msg.chat.id, 'Hello', opts);
    });
 bot.onText(/\Back/, function onLoveText(msg) {
      const opts = {
        reply_to_message_id: msg.message_id,
        reply_markup: JSON.stringify({
          keyboard: StartKeyboard,
          resize_keyboard:true,
          one_time_keyboard: true
        })
      };
      bot.sendMessage(msg.chat.id, 'Hello', opts);
    });
 bot.onText(/\Back/, function onLoveText(msg) {  //  I Can't Use Backkk
      const opts = {
        reply_to_message_id: msg.message_id,
        reply_markup: JSON.stringify({
          keyboard: BackKeyboard,
          resize_keyboard:true,
          one_time_keyboard: true
        })
      };
      bot.sendMessage(msg.chat.id, 'Hello', opts);
    });

enter image description here


Solution

  • Solved With callback_query and Inline Keyboards

    const helpKeyboard = [[{
        text: `back`,
        callback_data: `back3`
    }]]
    
    
    
    bot.on('callback_query', msg => {
     if (msg.data == `back3`) {
    }
    }