Event on Message Change ONIMBOTMESSAGEUPDATE
Scope:
imbotWho can subscribe: user of the application that registered the chat bot
The ONIMBOTMESSAGEUPDATE event is triggered when a message is modified in a dialogue with the chat bot. This event operates only within the context of the chat bot application.
For bots with TYPE=B/H and OPENLINE=N, the EVENT_MESSAGE_UPDATE parameter is ignored in the imbot.register method. To ensure the event is triggered for such bots, bind the EVENT_MESSAGE_UPDATE handler using the imbot.update method.
Events will not be sent to the application until the installation is complete. Check the application installation
Event Triggering Rule
The event is triggered if the EVENT_MESSAGE_UPDATE handler is bound and the message aligns with the bot type logic:
TYPE=B/H:- personal chat with the bot: the event triggers regardless of mentions,
- group chat: triggers only when the bot is mentioned,
TYPE=S— the event triggers regardless of mentions,TYPE=O— the event triggers in open line chats where the bot is involved.
Without EVENT_MESSAGE_UPDATE, the event will not trigger regardless of mentions.
What the Handler Receives
Data is transmitted as a POST request
{
"event": "ONIMBOTMESSAGEUPDATE",
"event_handler_id": "455",
"data": {
"BOT": {
"571": {
"access_token": "880aa0690000071b000008440000023bf0f107a4af72f200b757ece",
"expires": "1772096136",
"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": "7889c7690000071b000008440000023bf0f107ad212748fb2268",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "880aa0690000071b000008440000023bf0f107a4af72f200b757ece",
"expires": "1772096136",
"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": "7889c7690000071b000008440000023bf0f107ad212748fb2268",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"ID": "84531",
"CHAT_ID": "1453",
"AUTHOR_ID": "27",
"MESSAGE": "How to add an observer to the task?",
"MESSAGE_TYPE": "P",
"CHAT_AUTHOR_ID": "571",
"CHAT_ENTITY_ID": "",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"FROM_USER_ID": "27",
"TO_USER_ID": "571",
"CHAT_USER_COUNT": "2",
"PLATFORM_CONTEXT": "web",
"DIALOG_ID": "27",
"MESSAGE_ID": "84531",
"CHAT_TYPE": "P",
"LANGUAGE": "de"
},
"USER": {
"ID": "27",
"NAME": "Emily Smith",
"FIRST_NAME": "Emily",
"LAST_NAME": "Smith",
"WORK_POSITION": "",
"GENDER": "F",
"IS_BOT": "N",
"IS_CONNECTOR": "N",
"IS_NETWORK": "N",
"IS_EXTRANET": "N"
}
},
"ts": "1772092536",
"auth": {
"access_token": "880aa06900071b00084400001b0007dff360d21523410a45b4f7c12",
"expires": "1772096136",
"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": "7889c769000071b000084400001b00007c0063d012b7284",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
{
"event": "ONIMBOTMESSAGEUPDATE",
"event_handler_id": "455",
"data": {
"BOT": {
"571": {
"access_token": "2c1da06900071b00084400023bf0f107464a9d34dc68a6b185f",
"expires": "1772100908",
"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": "1c9cc76900071b00084400023bf0f107bbc698c8eca4b3e89099f4",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "2c1da06900071b00084400023bf0f107464a9d34dc68a6b185f",
"expires": "1772100908",
"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": "1c9cc76900071b00084400023bf0f107bbc698c8eca4b3e89099f4",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"ID": "84537",
"CHAT_ID": "1157",
"AUTHOR_ID": "27",
"MESSAGE": "create a task list",
"MESSAGE_TYPE": "C",
"CHAT_AUTHOR_ID": "27",
"CHAT_ENTITY_TYPE": "THREAD",
"CHAT_ENTITY_ID": "",
"CHAT_ENTITY_DATA_1": "",
"CHAT_ENTITY_DATA_2": "",
"CHAT_ENTITY_DATA_3": "",
"CHAT_USER_COUNT": "2",
"MENTIONED_LIST": {
"571": "571"
},
"PLATFORM_CONTEXT": "web",
"MESSAGE_ORIGINAL": "[USER=571]NewBot[/USER], create a task list",
"TO_USER_ID": "571",
"DIALOG_ID": "chat1157",
"MESSAGE_ID": "84537",
"CHAT_TYPE": "C",
"LANGUAGE": "de"
}
},
"ts": "1772097308",
"auth": {
"access_token": "2c1da06900071b00084400001b00077e03d155e8",
"expires": "1772100908",
"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": "1c9cc76900071b00084400001b00007b2dbee904c1",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
|
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 with user authorization parameters on behalf of which the event was triggered. The structure is described below |
Parameter data
|
Parameter |
Description |
|
BOT |
Set of authorization parameters for the bots to which the event is addressed. The key of the object is the bot identifier The structure is described below |
|
PARAMS |
Parameters of the modified message. The structure is described below |
|
USER |
Data of the message author. May be absent or empty. The structure is described below |
Parameter BOT
|
Parameter |
Description |
|
{BOT_ID} |
Data object of a specific bot. The key corresponds to the bot identifier, for example The structure is described below |
Element {BOT_ID}
|
Parameter |
Description |
|
access_token |
OAuth authorization token for the bot |
|
expires |
Moment when the token expires |
|
expires_in |
Lifetime of the token in seconds |
|
scope |
Scope within which the event occurred |
|
domain |
Bitrix24 address where the event occurred |
|
server_endpoint |
Address of the OAuth server for REST requests |
|
status |
Status indicator of the application on the account |
|
client_endpoint |
General path for calling REST API methods for the account where the event occurred |
|
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 |
Parameter PARAMS
|
Parameter |
Description |
|
ID |
Identifier of the message |
|
CHAT_ID |
Identifier of the chat |
|
AUTHOR_ID |
Identifier of the message author |
|
MESSAGE |
Text of the message after modification. In a group chat, the text is transmitted without BB-code mentioning the bot |
|
MESSAGE_TYPE |
Type of message Possible values:
|
|
CHAT_AUTHOR_ID |
Identifier of the chat owner |
|
CHAT_ENTITY_TYPE |
Type of the object to which the chat is linked |
|
CHAT_ENTITY_ID |
Identifier of the object to which the chat is linked |
|
CHAT_ENTITY_DATA_1 |
Additional data of the chat object — field 1 |
|
CHAT_ENTITY_DATA_2 |
Additional data of the chat object — field 2 |
|
CHAT_ENTITY_DATA_3 |
Additional data of the chat object — field 3 |
|
FROM_USER_ID |
Identifier of the message sender. This field is filled for personal chats |
|
TO_USER_ID |
Identifier of the recipient. In a personal chat, this is the identifier of the bot; in a group chat, it is the identifier of the user or bot to whom the message is addressed. A value of |
|
CHAT_USER_COUNT |
Number of participants in the chat |
|
MENTIONED_LIST |
Mentions of users in the message. This parameter depends on the chat type and is absent in personal dialogues. The structure is described below |
|
PLATFORM_CONTEXT |
Platform from which the message was sent |
|
MESSAGE_ORIGINAL |
Original text of the message with BB-code mentions. This parameter depends on the chat type and is absent in personal dialogues |
|
DIALOG_ID |
Identifier of the dialogue |
|
MESSAGE_ID |
Identifier of the message. Duplicates the |
|
CHAT_TYPE |
Type of chat. Possible values:
|
|
LANGUAGE |
Default language of Bitrix24 |
Parameter MENTIONED_LIST
|
Parameter |
Description |
|
{USER_ID} |
Identifier of the user or bot mentioned in the message |
Parameter USER
|
Parameter |
Description |
|
ID |
Identifier of the user |
|
NAME |
Full name of the user |
|
FIRST_NAME |
First name of the user |
|
LAST_NAME |
Last name of the user |
|
WORK_POSITION |
User's position |
|
GENDER |
Gender of the user: |
|
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
- Event on Sending Message ONIMBOTMESSAGEADD
- Event on Message Deletion ONIMBOTMESSAGEDELETE
- Send Message imbot.message.add
- Update Sent Message with imbot.message.update
- Delete Message imbot.message.delete
- Create a Chatbot imbot.register