สำหรับเอเจนต์ AI: markdown ของหน้านี้ — /docs-content-en/chats/commands.md ดัชนีเอกสาร — /llms.txt

บทความในเอกสารมีให้บริการเป็นภาษาอังกฤษในขณะนี้

Bot commands in a chat

GET /v1/chats/:dialogId/commands

Returns the bot commands the current user can call in a chat, together with short cards of those bots.

Parameters

Parameter Type Required Description
dialogId (path) string yes Dialog identifier: chatXXX for a group chat, a user ID for the personal dialog with that user, or me for the personal dialog with yourself. chatXXX is the data.items[].id field of recent dialogs, a user ID comes from GET /v1/users

The operation takes no query parameters. Any query parameter is refused with 400 INVALID_PARAMS.

Examples

curl — personal key

Terminal
curl -X GET "https://vibecode.bitrix24.com/v1/chats/chat42/commands" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X GET "https://vibecode.bitrix24.com/v1/chats/chat42/commands" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/commands', {
  "method": "GET",
  "headers": {
    "X-Api-Key": "YOUR_API_KEY"
  }
})
const result = await response.json()

JavaScript — OAuth application

javascript
const response = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/commands', {
  "method": "GET",
  "headers": {
    "X-Api-Key": "YOUR_APP_KEY",
    "Authorization": "Bearer USER_SESSION_TOKEN"
  }
})
const result = await response.json()

Response fields

Field Type Description
success boolean Always true on success
data.commands array Commands available in the chat
data.commands[].id number Command ID
data.commands[].botId number ID of the bot that owns the command. The bot card is the data.users element with the same id
data.commands[].command string Command text, starts with /, for example /echo
data.commands[].category string Name of the command group in the command list
data.commands[].common string Y — the command is available in all chats, N — only in the personal dialog with the bot and in chats with the bot
data.commands[].context string Command context
data.commands[].title string Command description
data.commands[].params string Hint for the command parameters
data.commands[].extranet string Y — the command is available to extranet users, N — it is not
data.users array Cards of the bots that own the commands
data.users[].id number Bot ID
data.users[].name string Bot name
data.users[].avatar string Avatar URL. An empty string if no avatar is set
data.users[].color string Bot color in #RRGGBB format
data.users[].type string User type — bot

Response example

JSON
{
  "success": true,
  "data": {
    "commands": [
      {
        "id": 73,
        "botId": 1163,
        "command": "/giphy",
        "category": "Giphy",
        "common": "Y",
        "context": "",
        "title": "Post an image that matches the given topic",
        "params": "text",
        "extranet": "Y"
      },
      {
        "id": 103,
        "botId": 1291,
        "command": "/echo",
        "category": "MyBot",
        "common": "Y",
        "context": "",
        "title": "Echo",
        "params": "text",
        "extranet": "N"
      }
    ],
    "users": [
      {
        "id": 1163,
        "name": "Giphy",
        "avatar": "https://example.bitrix24.com/upload/giphy.png",
        "color": "#1eb4aa",
        "type": "bot"
      },
      {
        "id": 1291,
        "name": "MyBot",
        "avatar": "",
        "color": "#df532d",
        "type": "bot"
      }
    ]
  }
}

Error response example

422 — there is no chat with this dialogId:

JSON
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "CHAT_NOT_FOUND",
    "hint": "dialogId must be a userId (number as string) for DMs or \"chat{N}\" for group chats. Examples: \"1\" for user 1, \"chat123\" for group chat 123. Create a group chat first via POST /v1/bots/:botId/chats if needed.",
    "b24Code": "CHAT_NOT_FOUND"
  }
}

Errors

HTTP Code Description
400 INVALID_PARAMS dialogId is neither a positive user ID, chatXXX, nor me, or a query parameter was passed
401 MISSING_API_KEY X-Api-Key was not passed
401 TOKEN_MISSING The key has no configured Bitrix24 tokens
403 SCOPE_DENIED The key lacks the im scope
403 WRITE_BLOCKED_READONLY_KEY The key is read-only, and either the request was not made with an employee's personal key or dialogId does not point to an existing dialog
403 BITRIX_ACCESS_DENIED Bitrix24 refused access to the chat
404 ENTITY_NOT_FOUND Bitrix24 did not find the object. The Bitrix24 code is in error.b24Code
422 BITRIX_ERROR Bitrix24 returned an error, the Bitrix24 code is in error.b24Code. If the chat does not exist, the code is CHAT_NOT_FOUND
429 RATE_LIMITED The Bitrix24 request limit was exceeded. The retry delay is in the Retry-After header
502 ME_ALIAS_RESOLUTION_FAILED The user could not be resolved when the me alias is used
502 BITRIX_UNAVAILABLE Bitrix24 is unavailable or returned a response that could not be read
503 BITRIX_TIMEOUT Bitrix24 did not respond within the time limit. The retry delay is in the Retry-After header

Full list of common API errors — Errors.

Known specifics

  • The list contains only commands of bots that are available to the current user in this dialog. Active chat membership is required.
  • For a read-only key, an existing dialog is chatXXX or a user ID from that employee's recent dialogs.

See also