Event Triggered by the Chat Bot Command ONIMCOMMANDADD
Scope:
imbotWho can subscribe: user of the application that registered the chat bot
The ONIMCOMMANDADD event is triggered when a user invokes a bot command in a chat.
Events will not be sent to the application until the installation is complete. Check the application installation
What the Handler Receives
Data is transmitted as a POST request
{
"event": "ONIMCOMMANDADD",
"event_handler_id": "1045",
"data": {
"COMMAND": {
"103": {
"access_token": "be4ca0690000071b006e2cf200050b0077317605eb83b25d2bd6",
"expires": "1772113086",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"refresh_token": "aecbc7690000071b006e2cf200050b007f827f47e120e49da",
"user_id": "1291",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "8e3ab48a764a9b02700e759d59e91125",
"AUTH": {
"access_token": "be4ca0690000071b006e2cf200050b0077317605eb83b25d2bd6",
"expires": "1772113086",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"refresh_token": "aecbc7690000071b006e2cf200050b007f827f47e120e49da",
"user_id": "1291",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "8e3ab48a764a9b02700e759d59e91125"
},
"BOT_ID": "1291",
"BOT_CODE": "BOT_GM",
"COMMAND": "echo",
"COMMAND_ID": "103",
"COMMAND_PARAMS": "test",
"COMMAND_CONTEXT": "TEXTAREA",
"MESSAGE_ID": "33899"
}
},
"PARAMS": {
"MESSAGE": "/echo test",
"TEMPLATE_ID": "acae8d22-4536-4f47-a276-2e3bdf866475",
"MESSAGE_TYPE": "P",
"FROM_USER_ID": "1269",
"DIALOG_ID": "1269",
"TO_CHAT_ID": "2737",
"AUTHOR_ID": "1269",
"SYSTEM": "N",
"TO_USER_ID": "1291",
"SKIP_USER_CHECK": "Y",
"PUSH": "Y",
"PUSH_IMPORTANT": "N",
"RECENT_ADD": "Y",
"RECENT_SKIP_AUTHOR": "N",
"CONVERT": "N",
"SKIP_COMMAND": "N",
"SKIP_COUNTER_INCREMENTS": "N",
"SILENT_CONNECTOR": "N",
"SKIP_CONNECTOR": "N",
"IMPORTANT_CONNECTOR": "N",
"NO_SESSION_OL": "N",
"FAKE_RELATION": "0",
"SKIP_URL_INDEX": "N",
"MESSAGE_ID": "33899",
"CHAT_TYPE": "P",
"LANGUAGE": "en"
},
"USER": {
"ID": "1269",
"NAME": "John Smith",
"FIRST_NAME": "John",
"LAST_NAME": "Smith",
"GENDER": "M"
}
},
"ts": "1772109486",
"auth": {
"access_token": "be4ca06900071b006e2cf200004f50005243fd374178cf59f7831",
"expires": "1772113086",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"user_id": "1269",
"refresh_token": "aecbc76900071b006e2cf200004f50000f2e62ee8e8baa598968",
"application_token": "8e3ab48a764a9b02700e759d59e91125"
}
}
{
"event": "ONIMCOMMANDADD",
"event_handler_id": "1035",
"data": {
"COMMAND": {
"99": {
"access_token": "f1ca0690000071b006e2cf20050b00074d9ed82e255b",
"expires": "1772100799",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"refresh_token": "af9bc7690000071b006e2cf2050b00074d5d4c29337afbc6bb",
"user_id": "1291",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "8e3ab48a764a9b02700e759d59e91125",
"AUTH": {
"access_token": "f1ca0690000071b006e2cf20050b00074d9ed82e255b",
"expires": "1772100799",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"refresh_token": "af9bc7690000071b006e2cf2050b00074d5d4c29337afbc6bb",
"user_id": "1291",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "8e3ab48a764a9b02700e759d59e91125"
},
"BOT_ID": "1291",
"BOT_CODE": "BOT_GM",
"COMMAND": "echo",
"COMMAND_ID": "99",
"COMMAND_PARAMS": "test",
"COMMAND_CONTEXT": "TEXTAREA",
"MESSAGE_ID": "33871"
}
},
"PARAMS": {
"MESSAGE": "/echo test",
"TEMPLATE_ID": "eb3d5b1c-0830-4728-a7a3-73e9745a90a1",
"MESSAGE_TYPE": "C",
"FROM_USER_ID": "1269",
"DIALOG_ID": "chat2725",
"TO_CHAT_ID": "2725",
"AUTHOR_ID": "1269",
"SYSTEM": "N",
"CHAT_ID": "2725",
"CHAT_PARENT_ID": "0",
"CHAT_PARENT_MID": "0",
"CHAT_TITLE": "New chat name",
"CHAT_AUTHOR_ID": "1291",
"CHAT_TYPE": "C",
"CHAT_AVATAR": "33079",
"CHAT_COLOR": "GREEN",
"CHAT_ENTITY_TYPE": "CHAT",
"CHAT_ENTITY_ID": "13",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"CHAT_EXTRANET": "N",
"CHAT_PREV_MESSAGE_ID": "0",
"CHAT_CAN_POST": "MEMBER",
"RID": "1269",
"IS_MANAGER": "N",
"BOT_IN_CHAT": {
"1291": "1291"
},
"SKIP_USER_CHECK": "Y",
"PUSH": "Y",
"PUSH_IMPORTANT": "N",
"RECENT_ADD": "Y",
"RECENT_SKIP_AUTHOR": "N",
"CONVERT": "N",
"SKIP_COMMAND": "N",
"SKIP_COUNTER_INCREMENTS": "N",
"SILENT_CONNECTOR": "N",
"SKIP_CONNECTOR": "N",
"IMPORTANT_CONNECTOR": "N",
"NO_SESSION_OL": "N",
"FAKE_RELATION": "0",
"SKIP_URL_INDEX": "N",
"MESSAGE_ID": "33871",
"LANGUAGE": "en"
},
"USER": {
"ID": "1269",
"NAME": "John Smith",
"FIRST_NAME": "John",
"LAST_NAME": "Smith",
"GENDER": "M"
}
},
"ts": "1772097199",
"auth": {
"access_token": "bf1ca06900071b006e2cf200004f500031d5d527f58a97b0768",
"expires": "1772100799",
"expires_in": "3600",
"scope": "imbot",
"domain": "some-domain.bitrix24.com",
"server_endpoint": "https://oauth.bitrix.info/rest/",
"status": "F",
"client_endpoint": "https://some-domain.bitrix24.com/rest/",
"member_id": "d897063e1ce7c5eb9f04b9751eef5915",
"user_id": "1269",
"refresh_token": "af9bc76900071b006e2cf200004f50080d2934573350daabf8",
"application_token": "8e3ab48a764a9b02700e759d59e91125"
}
}
|
Parameter |
Description |
|
event |
Symbolic code of the event. In this case — |
|
event_handler_id |
Identifier of the event handler |
|
data |
Object containing event data. The structure is described below |
|
ts |
Date and time the event was sent from the event queue |
|
auth |
Object containing the authorization parameters of the user on behalf of whom the event was triggered. The structure is described below |
Parameter data
|
Parameter |
Description |
|
COMMAND |
Set of invoked commands of the chat bot. The structure is described below |
|
PARAMS |
Parameters of the message in which the command was invoked. The structure is described below |
|
USER |
Data of the message author. It may be an empty object if The structure is described below |
Parameter COMMAND
|
Parameter |
Description |
|
{COMMAND_ID} |
Data object of a specific invoked command. The key corresponds to the command identifier, for example The structure is described below |
Element {COMMAND_ID}
|
Parameter |
Description |
|
access_token |
OAuth authorization token of the bot |
|
expires |
Moment of token expiration |
|
expires_in |
Token lifetime in seconds |
|
scope |
Scope within which the event occurred |
|
domain |
Address of Bitrix24 where the event occurred |
|
server_endpoint |
Address of the OAuth server for REST requests |
|
status |
Application status indicator on the account |
|
client_endpoint |
Base path for calling the REST API on the current account |
|
member_id |
Unique identifier of Bitrix24 |
|
refresh_token |
OAuth token for renewing the bot's authorization |
|
user_id |
Identifier of the bot user |
|
client_id |
Identifier of the application issued upon registration |
|
application_token |
Application token |
|
AUTH |
Authorization parameters of the bot in The structure is described below |
|
BOT_ID |
Identifier of the bot |
|
BOT_CODE |
Symbolic code of the bot |
|
COMMAND |
Symbolic code of the invoked command |
|
COMMAND_ID |
Identifier of the invoked command |
|
COMMAND_PARAMS |
Parameters with which the command was invoked |
|
COMMAND_CONTEXT |
Context of the command invocation. Possible values:
|
|
MESSAGE_ID |
Identifier of the message to which a response is required |
Parameter PARAMS
|
Parameter |
Description |
|
MESSAGE |
Text of the message with the command |
|
TEMPLATE_ID |
Identifier of the message template |
|
MESSAGE_TYPE |
Type of the message. Possible values:
|
|
FROM_USER_ID |
Identifier of the message sender |
|
DIALOG_ID |
Identifier of the dialog |
|
TO_CHAT_ID |
Identifier of the chat |
|
AUTHOR_ID |
Identifier of the message author |
|
SYSTEM |
Indicator of a system message: |
|
TO_USER_ID |
Identifier of the interlocutor in a personal chat. This parameter is available only for personal chats |
|
SKIP_USER_CHECK |
Skip user check: |
|
PUSH |
Indicator of sending a push notification: |
|
PUSH_IMPORTANT |
Indicator of an important push notification: |
|
RECENT_ADD |
Add message to the Recent chats list: |
|
RECENT_SKIP_AUTHOR |
Exclude author from updating the Recent chats list: |
|
CONVERT |
Indicator of message formatting conversion: |
|
SKIP_COMMAND |
Skip command processing in the message: |
|
SKIP_COUNTER_INCREMENTS |
Do not increment unread message counters: |
|
SILENT_CONNECTOR |
Send message to external connector without notification: |
|
SKIP_CONNECTOR |
Do not send message to external connectors: |
|
IMPORTANT_CONNECTOR |
Indicator of an important message for the connector: |
|
NO_SESSION_OL |
Do not create an Open Line session: |
|
FAKE_RELATION |
System value of the user's relation to the chat |
|
SKIP_URL_INDEX |
Do not index links from the message: |
|
MESSAGE_ID |
Identifier of the message |
|
CHAT_TYPE |
Type of the chat. Possible values:
|
|
LANGUAGE |
Default language of Bitrix24 |
|
CHAT_ID |
Identifier of the chat. This parameter is available only for group chats |
|
CHAT_PARENT_ID |
Identifier of the parent chat. This parameter is available only for group chats |
|
CHAT_PARENT_MID |
Identifier of the parent message. This parameter is available only for group chats |
|
CHAT_TITLE |
Title of the chat. This parameter is available only for group chats |
|
CHAT_AUTHOR_ID |
Identifier of the chat owner. This parameter is available only for group chats |
|
CHAT_AVATAR |
Identifier of the chat avatar. |
|
CHAT_COLOR |
Color scheme of the chat. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_ENTITY_TYPE |
Type of the object to which the chat is linked. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_ENTITY_ID |
Identifier of the object to which the chat is linked. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_ENTITY_DATA_1 |
Additional data of the chat object — field 1. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_ENTITY_DATA_2 |
Additional data of the chat object — field 2. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_ENTITY_DATA_3 |
Additional data of the chat object — field 3. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_EXTRANET |
Indicator of an extranet chat: |
|
CHAT_PREV_MESSAGE_ID |
Identifier of the previous message in the chat. This parameter depends on the chat type, it is absent in personal dialogs |
|
CHAT_CAN_POST |
Permission of the current user to send messages in the chat. This parameter depends on the chat type, it is absent in personal dialogs |
|
RID |
Identifier of the record of the user's relation to the chat. This parameter depends on the chat type, it is absent in personal dialogs |
|
IS_MANAGER |
Indicator of the manager role: |
|
BOT_IN_CHAT |
List of bots present in the chat. This parameter is available only for group chats. The structure is described below |
Parameter BOT_IN_CHAT
|
Parameter |
Description |
|
{BOT_ID} |
Identifier of the bot present in the chat |
Parameter USER
|
Parameter |
Description |
|
ID |
Identifier of the user |
|
NAME |
User's full name |
|
FIRST_NAME |
User's first name |
|
LAST_NAME |
User's last name |
|
GENDER |
User's gender: |
Parameter auth
Required parameters are marked with *
|
Name |
Description |
|
access_token |
Authorization token OAuth 2.0 |
|
expires_in |
Time in seconds until the token expires |
|
scope* |
Scope under which the event occurred |
|
domain* |
Address of Bitrix24 where the event occurred |
|
server_endpoint* |
Address of the Bitrix24 authorization server needed to refresh OAuth 2.0 tokens |
|
status* |
Status of the application that subscribed to this event:
|
|
client_endpoint* |
Common path for REST API method calls for Bitrix24 where the event occurred |
|
member_id* |
Identifier of Bitrix24 where the event occurred |
|
refresh_token |
Token for extending authorization OAuth 2.0 |
|
application_token* |
Token for secure event handling |
Authorization tokens are not always passed to the event handler. If the hit that initiated the event could not be linked to a specific Bitrix24 user, the tokens are not passed. Always check the contents of the auth key in the code.
It is recommended to store tokens obtained earlier during the application installation. Use them when working with the application interface in the form of embeds, widgets, and so on.
Continue Learning
- Event When Adding a Bot to a Chat ONIMBOTJOINCHAT
- Event on Sending Message ONIMBOTMESSAGEADD
- Event on Message Change ONIMBOTMESSAGEUPDATE
- Event on Message Deletion ONIMBOTMESSAGEDELETE