Event on Message Sent ONIMBOTMESSAGEADD
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.
Scope:
imbotWho can subscribe: user of the application that registered the chat bot
DEPRECATED
Development of this event has been halted. Please use ONIMBOTV2MESSAGEADD.
The ONIMBOTMESSAGEADD event is triggered when a message is sent in a dialogue with the chat bot. In a group chat, the event is triggered if the chat bot is mentioned.
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": "ONIMBOTMESSAGEADD",
"event_handler_id": "403",
"data": {
"BOT": {
"567": {
"access_token": "a98b9d690000071b0000084400000237f0f107589d1e",
"expires": "1771932585",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "990ac5690000071b0000084400000237",
"user_id": "567",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "a98b9d690000071b0000084400000237f0f107589d1e",
"expires": "1771932585",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "990ac5690000071b0000084400000237",
"user_id": "567",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "567",
"BOT_CODE": "BOT1"
}
},
"PARAMS": {
"MESSAGE": "Hello",
"TEMPLATE_ID": "796c45aa-70e5-45aa-930c-c7fb32710c62",
"MESSAGE_TYPE": "P",
"FROM_USER_ID": "27",
"DIALOG_ID": "27",
"TO_CHAT_ID": "1407",
"AUTHOR_ID": "27",
"SYSTEM": "N",
"TO_USER_ID": "567",
"PUSH": "Y",
"PUSH_IMPORTANT": "N",
"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",
"COMMAND_CONTEXT": "TEXTAREA",
"CHAT_USER_COUNT": "2",
"PLATFORM_CONTEXT": "web",
"MESSAGE_ID": "84331",
"CHAT_TYPE": "P",
"LANGUAGE": "en"
},
"USER": {
"ID": "27",
"NAME": "Svetlana Ivanova",
"FIRST_NAME": "Svetlana",
"LAST_NAME": "Ivanova",
"WORK_POSITION": "",
"GENDER": "F",
"IS_BOT": "N",
"IS_CONNECTOR": "N",
"IS_NETWORK": "N",
"IS_EXTRANET": "N"
}
},
"ts": "1771928985",
"auth": {
"access_token": "a98b9d690000071b000008440000001b0000071d8a2",
"expires": "1771932585",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"user_id": "27",
"refresh_token": "990ac569071b000008440000001b000007f80ccc35b5e3",
"application_token": "831c76b092f9f135d9b66c3a720757"
}
}
{
"event": "ONIMBOTMESSAGEADD",
"event_handler_id": "403",
"data": {
"BOT": {
"567": {
"access_token": "ccb69d690000071b0000084400000237f0f10799e08fc9016818e8b51ecc9f7b5342a5",
"expires": "1771943628",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "bc35c5690000071b0000084400000237f0f107abd386665cf9cfc96eaf25e017730bc5",
"user_id": "567",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "ccb69d690000071b0000084400000237f0f10799e08fc9016818e8b51ecc9f7b5342a5",
"expires": "1771943628",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"refresh_token": "bc35c5690000071b0000084400000237f0f107abd386665cf9cfc96eaf25e017730bc5",
"user_id": "567",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "567",
"BOT_CODE": "BOT1"
}
},
"PARAMS": {
"MESSAGE": ", how to set up the left menu",
"TEMPLATE_ID": "6d0eef7c-12b4-41e7-b709-887ba410ded3",
"MESSAGE_TYPE": "C",
"FROM_USER_ID": "27",
"DIALOG_ID": "chat1157",
"TO_CHAT_ID": "1157",
"AUTHOR_ID": "27",
"SYSTEM": "N",
"CHAT_ID": "1157",
"CHAT_TITLE": "Brown Chat #18",
"CHAT_AUTHOR_ID": "27",
"CHAT_TYPE": "C",
"CHAT_AVATAR": "0",
"CHAT_COLOR": "BROWN",
"CHAT_ENTITY_TYPE": "THREAD",
"CHAT_ENTITY_ID": "",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"CHAT_EXTRANET": "N",
"CHAT_PREV_MESSAGE_ID": "80961",
"CHAT_CAN_POST": "MEMBER",
"RID": "27",
"IS_MANAGER": "N",
"PUSH": "Y",
"PUSH_IMPORTANT": "N",
"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",
"COMMAND_CONTEXT": "TEXTAREA",
"CHAT_USER_COUNT": "2",
"MENTIONED_LIST": {
"567": "567"
},
"PLATFORM_CONTEXT": "web",
"MESSAGE_ORIGINAL": "[USER=567]NewBot[/USER] , how to set up the left menu",
"TO_USER_ID": "567",
"MESSAGE_ID": "84351",
"LANGUAGE": "en"
},
"USER": {
"ID": "27",
"NAME": "Svetlana Ivanova",
"FIRST_NAME": "Svetlana",
"LAST_NAME": "Ivanova",
"WORK_POSITION": "",
"GENDER": "F",
"IS_BOT": "N",
"IS_CONNECTOR": "N",
"IS_NETWORK": "N",
"IS_EXTRANET": "N"
}
},
"ts": "1771940028",
"auth": {
"access_token": "ccb69d690000071b000008440000001b0000078c69a6b996b744c26b73e80ddeda0052",
"expires": "1771943628",
"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": "bac1cd5c8940947a75e0d71b1a84e348",
"user_id": "27",
"refresh_token": "bc35c5690000071b000008440000001b000007b7a839f68bc2cdd19de2677410425077",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
|
Parameter |
Description |
|
event |
Event character code. In this case — |
|
event_handler_id |
Event handler identifier |
|
data |
Object with event data. Structure described below |
|
ts |
Date and time of event sending from the event queue |
|
auth |
Object with authorization parameters of the user on behalf of whom the event was triggered. Structure described below |
Parameter data
|
Parameter |
Description |
|
BOT |
Set of authorization parameters for the bots to which the message is intended. The object key is the bot identifier Structure described below |
|
PARAMS |
Message parameters. Structure described below |
|
USER |
Data of the message author. May be an empty object if Structure described below |
Parameter BOT
|
Parameter |
Description |
|
/{BOT_ID/} |
Data object of a specific bot. The key corresponds to the bot identifier, for example Structure described below |
Element /
|
Parameter |
Description |
|
access_token |
OAuth authorization token for the bot |
|
expires |
Moment of token expiration |
|
expires_in |
Token lifetime in seconds |
|
scope |
Scope within which the event occurred |
|
domain |
Bitrix24 address where the event occurred |
|
server_endpoint |
OAuth server address for REST requests |
|
status |
Application status indicator on the account |
|
client_endpoint |
Common path for REST API method calls for Bitrix24 where the event occurred |
|
member_id |
Unique Bitrix24 identifier |
|
refresh_token |
OAuth token for extending bot authorization |
|
user_id |
Bot user identifier |
|
client_id |
Application identifier issued during registration |
|
application_token |
Application token |
|
AUTH |
Bot authorization parameters in Structure described below |
|
BOT_ID |
Bot identifier |
|
BOT_CODE |
Bot character code |
Parameter PARAMS
|
Parameter |
Description |
|
MESSAGE |
Message text |
|
TEMPLATE_ID |
Message template identifier |
|
MESSAGE_TYPE |
Type of message. Possible values:
|
|
FROM_USER_ID |
Identifier of the message sender |
|
DIALOG_ID |
Identifier of the dialogue |
|
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 message recipient |
|
CHAT_ID |
Identifier of the chat. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_TITLE |
Title of the chat. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_AUTHOR_ID |
Identifier of the chat owner. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_TYPE |
Type of chat. Possible values:
|
|
CHAT_AVATAR |
Identifier of the chat avatar. |
|
CHAT_COLOR |
Chat color scheme. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_ENTITY_TYPE |
Type of the object to which the chat is attached. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_ENTITY_ID |
Identifier of the object to which the chat is attached. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_ENTITY_DATA_1 |
Additional data of the chat object — field 1. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_ENTITY_DATA_2 |
Additional data of the chat object — field 2. This parameter depends on the chat type and is absent in personal dialogue |
|
CHAT_ENTITY_DATA_3 |
Additional data of the chat object — field 3. This parameter depends on the chat type and is absent in personal dialogue |
|
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 and is absent in personal dialogue |
|
CHAT_CAN_POST |
Current user's rights to send messages in the chat. This parameter depends on the chat type and is absent in personal dialogue |
|
RID |
Identifier of the user's connection record with the chat, system parameter |
|
IS_MANAGER |
Indicator of manager role: |
|
PUSH |
Indicator of sending a push notification: |
|
PUSH_IMPORTANT |
Indicator of an important push notification: |
|
RECENT_SKIP_AUTHOR |
Indicator of excluding the author from the Recent Chats list: |
|
CONVERT |
Indicator of message formatting conversion: |
|
SKIP_COMMAND |
Skip processing commands in the message: |
|
SKIP_COUNTER_INCREMENTS |
Do not increment unread counters: |
|
SILENT_CONNECTOR |
Send message to 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 with the chat |
|
SKIP_URL_INDEX |
Do not index links from the message: |
|
COMMAND_CONTEXT |
Command input context |
|
CHAT_USER_COUNT |
Number of participants in the chat. This parameter depends on the chat type and is absent in personal dialogue |
|
MENTIONED_LIST |
User mentions in the message. This parameter depends on the chat type and is absent in personal dialogue Structure described below |
|
PLATFORM_CONTEXT |
Platform from which the message was sent |
|
MESSAGE_ORIGINAL |
Original message text with BB code. This parameter depends on the chat type and is absent in personal dialogue |
|
MESSAGE_ID |
Message identifier |
|
LANGUAGE |
Default Bitrix24 language |
Parameter MENTIONED_LIST
|
Parameter |
Description |
|
{USER_ID} |
Identifier of the user or bot mentioned in the message |
Parameter USER
|
Parameter |
Description |
|
ID |
User identifier |
|
NAME |
User's full name |
|
FIRST_NAME |
User's first name |
|
LAST_NAME |
User's last name |
|
WORK_POSITION |
User's job title |
|
GENDER |
User's gender: |
|
IS_BOT |
Indicator of a bot user: |
|
IS_CONNECTOR |
Indicator of a connector user: |
|
IS_NETWORK |
Indicator of an external network user: |
|
IS_EXTRANET |
Indicator of an extranet user: |
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
- Overview of Events When Working with Messages
- Event on Message Update ONIMBOTMESSAGEUPDATE
- Event on Message Deletion ONIMBOTMESSAGEDELETE
- Send Message imbot.message.add
- Update Sent Message imbot.message.update
- Delete Message imbot.message.delete