Custom keyboards are essentially toolbars containing one or more user defined buttons. The keyboards provide alternative means of input, allowing a user to communicate with a chatbot by clicking the buttons.

Note: The example uses the restCommand function. It is
used here for illustration only. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.

Each button in the keyboard is defined by the following keys:

TEXT - specifies the button text;

LINK - specifies a hyperlink;

COMMAND - a command to send to the bot;

COMMAND_PARAMS - specifies command parameters;

BG_COLOR - specifies the button color;

BLOCK - if set to Y, the keyboard will be disabled after this button is clicked;

DISABLED - specify Y to disable the button;

TEXT_COLOR - specifies the button text color;

DISPLAY - specifies the button layout in the row. If set to BLOCK, only this button can occupy the row. If set to LINE, the buttons will be aligned one after the other;

WIDTH - button width in pixels. Try to avoid making buttons wider than 255 pixels, because it's the maximum width on mobile devices.

APP_ID - specifies the ID of an installed chat application.

APP_PARAMS - parameters that will be passed over to the chat application.

The TEXT key is required. To perform sensible action, one of the LINK and COMMAND keys are required as well.

If the LINK key is not empty, the button is treated as an external link. If COMMAND and COMMAND_PARAMS keys are specified, the button sends command to the bot.

If the APP_ID and APP_PARAMS keys are specified, the button will open a chat application window.

To start a new row of buttons, add a button containing only one key: "TYPE" => "NEWLINE".

Command Processing on the Chatbot Side

Chatbots use commands to process button clicks.

To make a command recognizable, it has to be registered using the imbot.command.register
(method in the ONAPPINSTALL event handler. To make the command available only from the keyboard, add the "HIDDEN" => "Y" key).