{% note tip "" %}
Choose a tool for developing with an AI agent:
- use Alaio Vibecode to build an app for Bitrix24 from a task description without knowing any programming language. The agent writes the code and deploys the app to a server, with no manual hosting setup
- use the MCP server to develop a REST API integration in your own project. The agent refers to the official REST documentation
{% endnote %}
Scope:
imbotWho can execute the method: a user of the application that registered the chat bot
{% note warning "DEPRECATED" %}
Development of this method has been halted. Please use imbot.v2.Command.answer.
{% endnote %}
The method imbot.command.answer publishes a response to a chat bot command.
{% include Note on required parameters %}
#|
|| Name
type | Description ||
|| COMMAND_ID*
integer | Command identifier. Required if COMMAND is not provided ||
|| COMMAND*
string | Command text. Required if COMMAND_ID is not provided ||
|| MESSAGE_ID*
integer | Identifier of the message to which the response is sent.
The identifier can be obtained from the incoming event ONIMCOMMANDADD ||
|| MESSAGE
string | Response text ||
|| ATTACH
object | Object with an attachment to the message. Minimum format:
{
"BLOCKS": [
{ "MESSAGE": "Block text" }
]
}Detailed description ||
|| KEYBOARD
object | Message keyboard. Minimum format:
{
"BUTTONS": [
{ "TEXT": "Repeat", "COMMAND": "echo repeat" }
]
}Detailed description ||
|| MENU
object | Context menu of the message. Minimum format:
[
{ "TEXT": "bitrix24", "LINK": "https://bitrix24.com" }
]Detailed description ||
|| SYSTEM
string | Message type:
Y- system messageN- regular message
Default is N ||
|| URL_PREVIEW
string | Link transformation into rich links:
Y- enabledN- disabled
Default is Y.
Works for links provided in the MESSAGE field ||
|| CLIENT_ID
string | This parameter is required only for webhooks. Pass the same CLIENT_ID that was specified during the registration of the chat bot ||
|#
{% include Note on examples %}
{% list tabs %}
-
cURL (Webhook)
curl -X POST / -H "Content-Type: application/json" / -H "Accept: application/json" / -d '{"COMMAND_ID":99,"MESSAGE_ID":33871,"MESSAGE":"Accepted. Executing command.","SYSTEM":"N","URL_PREVIEW":"Y","ATTACH":{"BLOCKS":[{"MESSAGE":"Task details"},{"DELIMITER":true},{"LINK":{"NAME":"Open","LINK":"https://example.com"}}]},"KEYBOARD":{"BUTTONS":[{"TEXT":"Repeat","COMMAND":"echo repeat"}]},"MENU":[{"TEXT":"bitrix24","LINK":"https://bitrix24.com"}],"CLIENT_ID":"**put_your_client_id_here**"}' / https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/imbot.command.answer
-
cURL (OAuth)
curl -X POST / -H "Content-Type: application/json" / -H "Accept: application/json" / -d '{"COMMAND_ID":99,"MESSAGE_ID":33871,"MESSAGE":"Accepted. Executing command.","SYSTEM":"N","URL_PREVIEW":"Y","ATTACH":{"BLOCKS":[{"MESSAGE":"Task details"},{"DELIMITER":true},{"LINK":{"NAME":"Open","LINK":"https://example.com"}}]},"KEYBOARD":{"BUTTONS":[{"TEXT":"Repeat","COMMAND":"echo repeat"}]},"MENU":[{"TEXT":"bitrix24","LINK":"https://bitrix24.com"}],"auth":"**put_access_token_here**"}' / https://**put_your_bitrix24_address**/rest/imbot.command.answer
-
JS
try { const response = await $b24.callMethod( 'imbot.command.answer', { COMMAND_ID: 99, MESSAGE_ID: 33871, MESSAGE: 'Accepted. Executing command.', SYSTEM: 'N', URL_PREVIEW: 'Y', ATTACH: { BLOCKS: [ {MESSAGE: 'Task details'}, {DELIMITER: true}, {LINK: {NAME: 'Open', LINK: 'https://example.com'}} ] }, KEYBOARD: { BUTTONS: [ {TEXT: 'Repeat', COMMAND: 'echo repeat'} ] }, MENU: [ {TEXT: 'bitrix24', LINK: 'https://bitrix24.com'} ] } ); const result = response.getData().result; console.log('Answered command with ID:', result); processResult(result); } catch( error ) { console.error('Error:', error); }
-
PHP
try { $response = $b24Service ->core ->call( 'imbot.command.answer', [ 'COMMAND_ID' => 99, 'MESSAGE_ID' => 33871, 'MESSAGE' => 'Accepted. Executing command.', 'SYSTEM' => 'N', 'URL_PREVIEW' => 'Y', 'ATTACH' => [ 'BLOCKS' => [ ['MESSAGE' => 'Task details'], ['DELIMITER' => true], ['LINK' => ['NAME' => 'Open', 'LINK' => 'https://example.com']] ] ], 'KEYBOARD' => [ 'BUTTONS' => [ ['TEXT' => 'Repeat', 'COMMAND' => 'echo repeat'] ] ], 'MENU' => [ ['TEXT' => 'bitrix24', 'LINK' => 'https://bitrix24.com'] ] ] ); $result = $response ->getResponseData() ->getResult(); echo 'Success: ' . print_r($result, true); processData($result); } catch (Throwable $e) { error_log($e->getMessage()); echo 'Error answering command: ' . $e->getMessage(); }
-
BX24.js
BX24.callMethod( 'imbot.command.answer', { COMMAND_ID: 99, MESSAGE_ID: 33871, MESSAGE: 'Accepted. Executing command.', SYSTEM: 'N', URL_PREVIEW: 'Y', ATTACH: { BLOCKS: [ {MESSAGE: 'Task details'}, {DELIMITER: true}, {LINK: {NAME: 'Open', LINK: 'https://example.com'}} ] }, KEYBOARD: { BUTTONS: [ {TEXT: 'Repeat', COMMAND: 'echo repeat'} ] }, MENU: [ {TEXT: 'bitrix24', LINK: 'https://bitrix24.com'} ] }, function(result) { if (result.error()) console.error(result.error()); else console.dir(result.data()); } );
-
PHP CRest
require_once('crest.php'); $result = CRest::call( 'imbot.command.answer', [ 'COMMAND_ID' => 99, 'MESSAGE_ID' => 33871, 'MESSAGE' => 'Accepted. Executing command.', 'SYSTEM' => 'N', 'URL_PREVIEW' => 'Y', 'ATTACH' => [ 'BLOCKS' => [ ['MESSAGE' => 'Task details'], ['DELIMITER' => true], ['LINK' => ['NAME' => 'Open', 'LINK' => 'https://example.com']] ] ], 'KEYBOARD' => [ 'BUTTONS' => [ ['TEXT' => 'Repeat', 'COMMAND' => 'echo repeat'] ] ], 'MENU' => [ ['TEXT' => 'bitrix24', 'LINK' => 'https://bitrix24.com'] ] ] ); echo '<PRE>'; print_r($result); echo '</PRE>';
-
Go
// client and ctx are already created — see the Go SDK section res, err := client.Core().Call(ctx, "imbot.command.answer", b24.Params{ "COMMAND_ID": 99, "MESSAGE_ID": 33871, "MESSAGE": "Accepted. Executing command.", "SYSTEM": "N", "URL_PREVIEW": "Y", "ATTACH": b24.Params{ "BLOCKS": []b24.Params{ { "MESSAGE": "Task details", }, { "DELIMITER": true, }, { "LINK": b24.Params{ "NAME": "Open", "LINK": "https://example.com", }, }, }, }, "KEYBOARD": b24.Params{ "BUTTONS": []b24.Params{ { "TEXT": "Repeat", "COMMAND": "echo repeat", }, }, }, "MENU": []b24.Params{ { "TEXT": "bitrix24", "LINK": "https://bitrix24.com", }, }, "CLIENT_ID": "**put_your_client_id_here**", }) if err != nil { return fmt.Errorf("imbot.command.answer: %w", err) } var value b24.ID if err := json.Unmarshal(res.Result, &value); err != nil { return fmt.Errorf("parse response: %w", err) } fmt.Println("result:", value)
{% endlist %}
HTTP Status: 200
{
"result": 33879,
"time": {
"start": 1772102358,
"finish": 1772102359.061859,
"duration": 1.061858892440796,
"processing": 1,
"date_start": "2026-02-26T13:39:18+01:00",
"date_finish": "2026-02-26T13:39:19+01:00",
"operating_reset_at": 1772102958,
"operating": 0
}
}#|
|| Name
type | Description ||
|| result
integer | Identifier of the sent response message ||
|| time
time | Information about the request execution time ||
|#
HTTP Status: 400
{
"error": "MESSAGE_EMPTY",
"error_description": "Message can't be empty"
}{% include notitle error handling %}
#|
|| Code | Description | Value ||
|| COMMAND_ID_ERROR | Command not found | Command not found ||
|| APP_ID_ERROR | Command was installed by another rest application | Command registered by another application ||
|| MESSAGE_ID_EMPTY | Message ID can't be empty | MESSAGE_ID not provided ||
|| MESSAGE_EMPTY | Message can't be empty | Message text not provided ||
|| ATTACH_ERROR | Incorrect attach params | Invalid ATTACH object ||
|| ATTACH_OVERSIZE | You have exceeded the maximum allowable size of attach | ATTACH size exceeds the allowable limit ||
|| KEYBOARD_ERROR | Incorrect keyboard params | Invalid KEYBOARD object ||
|| KEYBOARD_OVERSIZE | You have exceeded the maximum allowable size of keyboard | KEYBOARD size exceeds the allowable limit ||
|| MENU_ERROR | Incorrect menu params | Invalid MENU object ||
|| WRONG_REQUEST | Message isn't added | Failed to send message ||
|#
{% include system errors %}