0stone0: fixed the problem; thank you, thank you + thank you;
ADW: thank you for illustrating keyboard object, adopted;
Google web app based on JavaScript to send JSON objects to a Telegram bot; implementing Telegram based menu using buttons, in order for the user to press selected button and execution of corresponding action;
user types: menu
list of buttons show up on the Telegram group screen
solution follows:
function menu( chat_id ) {
let url = vUrlTelegram + "/sendMessage";
var keyboard = {
'inline_keyboard' :
[
[{'text' : 'admin', 'callback_data' : 'admin'}], // Row 1
[{'text' : 'squad', 'callback_data' : 'squad'}], // Row 2
[{'text' : 'carioca', 'callback_data' : 'carioca'}], // Row 3
[{'text' : 'brasileiro', 'callback_data' : 'brasileiro'}], // Row 4
[{'text' : 'sponsors', 'callback_data' : 'sponsors'}], // Row 5
[{'text' : 'test', 'callback_data' : 'test'}] // Row 6
]
};
var data = {
'chat_id': chat_id,
'text': "main menu",
'reply_markup': keyboard
};
var options = {
'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
2
Answers
This assumes you are trying to send an inline keyboard to Telegram using Google Apps Script.
I’ve written this sample script that may help:
Just had a busy weekend 😉
Managed to make it work in Google App Script;
Problem was due the nested payload / reply_markup objects.