For AI agents: markdown of this page — /docs-content-en/bots/commands/answer.md documentation index — /llms.txt

Answer a command

POST /v1/bots/:botId/commands/:commandId/answer

Sends a reply to a slash-command invocation. Call it from the ONIMBOTV2COMMANDADD event handler.

Request fields (body)

Parameter Type Required Description
messageId number yes ID of the message that invoked the command (from the event)
dialogId string yes Dialog ID. For a group chat — chat{chatId}, for a private chat — {userId}. Take it from the ONIMBOTV2COMMANDADD event (PARAMS.DIALOG_ID)
fields object no Reply message fields
fields.message string no Reply text. Supports BB-codes
fields.keyboard array no Interactive keyboard
fields.attach array/object no ATTACH blocks
fields.system boolean no System message. Defaults to false
fields.urlPreview boolean no Show link previews. Defaults to true

Examples

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/commands/7/answer \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messageId": 1510,
    "dialogId": "chat123",
    "fields": {
      "message": "[b]Task help[/b]\n\nAvailable actions:\n[SEND=/status]Check status[/SEND]\n[SEND=/create]Create task[/SEND]"
    }
  }'

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/bots/42/commands/7/answer \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messageId": 1510,
    "dialogId": "chat123",
    "fields": {
      "message": "[b]Task help[/b]\n\nAvailable actions:\n[SEND=/status]Check status[/SEND]\n[SEND=/create]Create task[/SEND]"
    }
  }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/commands/7/answer', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    messageId: 1510,
    dialogId: 'chat123',
    fields: {
      message: '[b]Task help[/b]\n\nAvailable actions:\n[SEND=/status]Check status[/SEND]',
    },
  }),
})

const { success, data } = await res.json()

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/bots/42/commands/7/answer', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    messageId: 1510,
    dialogId: 'chat123',
    fields: {
      message: '[b]Task help[/b]\n\nAvailable actions:\n[SEND=/status]Check status[/SEND]',
    },
  }),
})

const { success, data } = await res.json()

Response fields

Field Type Description
data.result boolean true when the reply was sent successfully

Response example

JSON
{
  "success": true,
  "data": {
    "result": true
  }
}

Error response example

404 — bot not found:

JSON
{
  "success": false,
  "error": {
    "code": "BOT_NOT_FOUND",
    "message": "Bot 999 not found. Register it first via POST /v1/bots."
  }
}

Errors

HTTP Code Description
400 INVALID_BOT_ID botId is not a number
404 BOT_NOT_FOUND No bot found with this ID
403 BOT_ACCESS_DENIED The bot belongs to a different API key
422 BITRIX_ERROR Bitrix24 error (error text in message)
403 SCOPE_DENIED API key lacks the imbot scope
401 TOKEN_MISSING API key has no configured tokens

Full list of common API errors — Errors.

Known specifics

No chat membership required: the bot can answer a command even if it is not a participant of the chat. Access is granted temporarily through the messageId + commandId pair. If the bot is not a participant, the reply is sent as a system message under the bot's name.

See also