Skip to main content

Generate keyboard from array of buttons

Generates a simple JSON keyboard from an array of buttons for a message or bottom panel

Function FormKeyboardFromButtonArray(Val ButtonArray, Val UnderMessage = False, Val OneByOne = True) Export

ParameterCLI optionTypeRequiredDescription
ButtonArray--buttonsArray of StringArray of buttons
UnderMessage--underBooleanKeyboard under the message or on the bottom panel
OneByOne--columnBooleanTrue > buttons are displayed in a column, False > in a row

Returns: String - Keyboard JSON


tip

About keyboards in the API documentation: InlineKeyboardMarkup


1C:Enterprise/OneScript code example
    ButtonArray = New Array;
ButtonArray.Add("Button1");
ButtonArray.Add("Button2");
ButtonArray.Add("Button3");

Result = OPI_Telegram.FormKeyboardFromButtonArray(ButtonArray);
    oint telegram FormKeyboardFromButtonArray \
--buttons "['Button1','Button2','Button3']"
Result
"{\r\n \"keyboard\": [\r\n  [\r\n   {\r\n    \"text\": \"Button1\",\r\n    \"callback_data\": \"Button1\"\r\n   }\r\n  ],\r\n  [\r\n   {\r\n    \"text\": \"Button2\",\r\n    \"callback_data\": \"Button2\"\r\n   }\r\n  ],\r\n  [\r\n   {\r\n    \"text\": \"Button3\",\r\n    \"callback_data\": \"Button3\"\r\n   }\r\n  ]\r\n ],\r\n \"resize_keyboard\": true\r\n}"