Aleksey Bondarev
Aleksey Bondarev

Reputation: 1

Telegram bot Keyboard not working

I craete the Telegram bot on GAS, but my custom keyboard do not working. My functon send message is below. Thanks.

function sendText(text,chatId){

var payload = { 'method': 'sendMessage', 'chat_id': String(chatId), 'text': text, 'parse_mode': 'HTML' }

    var data = {
      "method": "post",
      "payload": payload,
      "reply_markup": JSON.stringify({
        'keyboard': [['Store username']],
        'resize_keyboard':true,
        'one_time_keyboard': true
      })
    }

    // Replace with your token
    var API_TOKEN = '**********************';
    UrlFetchApp.fetch('https://api.telegram.org/bot' + API_TOKEN + '/', data);

}

Upvotes: 0

Views: 2099

Answers (1)

Sadegh PM
Sadegh PM

Reputation: 452

According to telegram official api your keyboard format must be:

Array of button rows, each represented by an Array of KeyboardButton objects

for example :

"reply_markup": JSON.stringify({
    'keyboard': [
                 [ ['row1-col1'] ],//row 1
                 [ ['row2-col1'],['row2-col2'] ] //row 2
                 ],
    'resize_keyboard':true,
    'one_time_keyboard': true
  })

Upvotes: 2

Related Questions