Event When Adding a Bot to a Chat ONIMBOTJOINCHAT
Scope:
imbotWho can subscribe: a user of the application that registered the chat bot
The event ONIMBOTJOINCHAT is triggered when a bot is added to 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 in the form of a POST request
{
"event": "ONIMBOTJOINCHAT",
"event_handler_id": "459",
"data": {
"BOT": {
"571": {
"access_token": "e703a069000071b00084400023bf0f10751a702af1e",
"expires": "1772094439",
"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": "d782c76900071b00084400023bf0f1077047d2feeb6c5f3fb",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "e703a069000071b00084400023bf0f10751a702af1e",
"expires": "1772094439",
"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": "d782c76900071b00084400023bf0f1077047d2feeb6c5f3fb",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"CHAT_TYPE": "P",
"MESSAGE_TYPE": "P",
"BOT_ID": "571",
"USER_ID": "27",
"TO_USER_ID": "27",
"FROM_USER_ID": "571",
"DIALOG_ID": "27",
"LANGUAGE": "de"
},
"USER": {
"ID": "27",
"NAME": "Emily Smith",
"FIRST_NAME": "Emily",
"LAST_NAME": "Smith",
"WORK_POSITION": "",
"GENDER": "F"
}
},
"ts": "1772090839",
"auth": {
"access_token": "e703a069000071b00084400001b00074523806a5537056abff",
"expires": "1772094439",
"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",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
}
}
{
"event": "ONIMBOTJOINCHAT",
"event_handler_id": "459",
"data": {
"BOT": {
"571": {
"access_token": "4d12a06900071b00084400023bf0f1079c6f8b9190c698fd2",
"expires": "1772098125",
"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": "3d91c7690000071b00084400023bf0f107580dad11018e",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757",
"AUTH": {
"access_token": "4d12a06900071b00084400023bf0f1079c6f8b9190c698fd2",
"expires": "1772098125",
"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": "3d91c7690000071b00084400023bf0f107580dad11018e",
"user_id": "571",
"client_id": "a7eff906dd1d950269258a599214f69e",
"application_token": "831c76b092f9f135d9b6b36c3a720757"
},
"BOT_ID": "571",
"BOT_CODE": "BOT"
}
},
"PARAMS": {
"CHAT_TYPE": "C",
"MESSAGE_TYPE": "C",
"BOT_ID": "571",
"USER_ID": "27",
"CHAT_ID": "1157",
"CHAT_AUTHOR_ID": "27",
"CHAT_ENTITY_TYPE": "THREAD",
"CHAT_ENTITY_ID": "",
"ACCESS_HISTORY": "1",
"DIALOG_ID": "chat1157",
"LANGUAGE": "de"
},
"USER": {
"ID": "27",
"NAME": "Emily Smith",
"FIRST_NAME": "Emily",
"LAST_NAME": "Smith",
"WORK_POSITION": "",
"GENDER": "F"
}
},
"ts": "1772094525",
"auth": {
"access_token": "4e12a06900071b00084400001b000070de69612254f5f11a912b908",
"expires": "1772098126",
"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",
"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 containing the authorization parameters of the user on behalf of whom 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 directed. The object key is the bot identifier The structure is described below |
|
PARAMS |
Event parameters. The structure is described below |
|
USER |
Data of the user who added the bot to the chat. It may be an empty object if 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 |
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 |
General path for calling REST API methods on 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 |
|
CHAT_TYPE |
Type of chat to which the bot was added. Possible values:
|
|
MESSAGE_TYPE |
Type of message. Possible values:
|
|
BOT_ID |
Identifier of the bot |
|
USER_ID |
Identifier of the user who added the bot |
|
TO_USER_ID |
Identifier of the user with whom the personal dialog was created. This parameter is only for personal chat |
|
FROM_USER_ID |
Identifier of the bot in the personal dialog. This parameter is only for personal chat |
|
CHAT_ID |
Identifier of the group chat. This parameter is only for group chat |
|
CHAT_AUTHOR_ID |
Identifier of the owner of the group chat. This parameter is only for group chat |
|
CHAT_ENTITY_TYPE |
Type of the object to which the group chat is linked. This parameter is only for group chat |
|
CHAT_ENTITY_ID |
Identifier of the object to which the group chat is linked. This parameter is only for group chat |
|
ACCESS_HISTORY |
Indicator of the bot's access to history: |
|
SILENT_JOIN |
Indicator of adding the bot without a system message: |
|
DIALOG_ID |
Identifier of the dialog |
|
LANGUAGE |
Default language of Bitrix24 |
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: |
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 Change ONIMBOTMESSAGEUPDATE
- Event on Message Deletion ONIMBOTMESSAGEDELETE
- Event for Deleting a Chatbot ONIMBOTDELETE