-4

I want to use for loop in telegram reply keyboard. this is my code:

var keyboard = [];

for (var i = 0; i < 5; i++) {
   keyboard.push([{'text': 'Device'+i}]);
}

var payload = {
    
   'method': 'sendMessage',
   'chat_id': String(chatId),
   'text': text,
   'reply_markup': JSON.stringify({
      inline_keyboard: keyboard
   })
}
      
var data = {
     "method": "post",
     "payload": payload,          
}
      
UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);

My code seems true, but don't work, and don't show replay keyboard :(

i also read this post , but don't help to me generate inline keyboard telegram bot from the database

Tibebes. M
  • 6,940
  • 5
  • 15
  • 36
HOSSEIN IZADI
  • 35
  • 1
  • 1
  • 8

1 Answers1

0

I think you missed callback_data

Try this:

keyboard.push([{'text': 'Device'+i, 'callback_data': 'data'}]);

Awesome Telegram Bot

Sean Wei
  • 7,433
  • 1
  • 19
  • 39