Views: 2092
Last Modified: 13.05.2022

Publishes response to command

Attention! restCommand function is used here for illustration purposes only. It is taken from the EchoBot example. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.

Note: Command processing requires for application to process a command-adding event ONIMCOMMANDADD.

Method call

$result = restCommand('imbot.command.answer', Array(

    'COMMAND_ID' => 13, // ID for command that prepared the report, (required to be specified or COMMAND)
    'COMMAND' => 'echo', // Name of command that prepared the answer (required to be specified or COMMAND_ID)
    'MESSAGE_ID' => 1122, // ID for message that requires an answer
    'MESSAGE' => 'answer text' // Answer text
    'ATTACH' => '' // Attachment, optional field
    'KEYBOARD' => '' // Keyboard, optional field
    'MENU' => '' // Context menu, optional field
    'SYSTEM' => 'N' // Display messages as system message, optional field, 'N' by default
    'URL_PREVIEW' => 'Y' // Convert links to rich-links, optional field, 'Y' by default
    'CLIENT_ID' => '', // Chatbot string ID, used only in Webhooks mode

), $_REQUEST["auth"]);


Command MESSAGE_ID or error.

Related links:

Possible error codes

Code Description
COMMAND_ID_ERROR Command not found.
APP_ID_ERROR Chatbot is not part of this application: you can only work with chatbots, installed within application frameworkприложения.
MESSAGE_EMPTY Message text is not transmitted.
ATTACH_ERROR Complete transmitted attachment object was not validated.
ATTACH_OVERSIZE Maximum permissible attachment size was exceeded (30 Kb).
KEYBOARD_ERROR Complete transmitted keyboard object was not validated.
KEYBOARD_OVERSIZE Maximum permissible keyboard size was exceeded (30 Kb).
MENU_ERROR Complete transmitted object menu was not validated.
MENU_OVERSIZE Maximum permissible menu size was exceeded (30 Kb).
WRONG_REQUEST Something went wrong.

Courses developed by Bitrix24