Widget for IM_SIDEBAR
Scope:
im
You can add your item to the chat sidebar.
The widget code is specified in the PLACEMENT parameter of the placement.bind method.
The widget will not be displayed in the interface until the application installation is complete. Check the application installation
Where the widget is embedded
|
Widget Code |
Location |
|
|
Item in the chat sidebar |
Where to find it in the interface
Open the chat and click the sidebar button on the right side of the top chat panel. In the opened sidebar, there is an Applications block at the bottom, which displays the application item with PLACEMENT=IM_SIDEBAR.
What the handler receives
Data is transmitted as a POST request
Array
(
[DOMAIN] => xxx.bitrix24.com
[PROTOCOL] => 1
[LANG] => de
[APP_SID] => 99c80eff6378726287350416ee5fef0
[AUTH_ID] => 6061e72600631fcd00005a4b00000001f0f1076700000000f69dd5fc643d9ce2fdbc1
[AUTH_EXPIRES] => 3600
[REFRESH_ID] => 50e00aa340631fcd00005a4b00000001f0f1071111116580a5b83c2de639ef28c12
[member_id] => da45a03b265ed12127f8a258d793cc5d
[status] => F
[PLACEMENT] => IM_SIDEBAR
[PLACEMENT_OPTIONS] => {"dialogId":"chat1489"}
)
Required parameters are marked with *
|
Parameter |
Description |
|
DOMAIN* |
The Bitrix24 address where the widget handler was invoked |
|
PROTOCOL* |
Secure or non-secure HTTP protocol:
|
|
LANG* |
The user interface language of Bitrix24 that invoked the widget. You can localize the interface language in your widget based on this value |
|
APP_SID |
String identifier of the application that registered the widget handler |
|
AUTH_ID |
Authorization token OAuth 2 issued for the user who invoked the widget. Can be used for REST API calls on behalf of this user |
|
AUTH_EXPIRES |
Time in seconds after which the authorization token will become invalid |
|
REFRESH_ID |
Refresh token OAuth 2 issued for the user who invoked the widget. Can be used to refresh the authorization token on behalf of this user |
|
member_id* |
Unique string identifier of Bitrix24 where the widget handler was invoked. |
|
status |
Type of application that registered the handler for this widget. Accepts values:
|
|
PLACEMENT* |
Code for the widget embedding location. You can use the same handler URL for all your widgets. The value that Bitrix24 will report in the |
|
PLACEMENT_OPTIONS |
Additional data in the form of a JSON string that defines the context of the widget execution. For example, this could be an array containing the numeric identifier of the CRM entity in the detail form where the widget handler was invoked, etc. The |
PLACEMENT_OPTIONS
The value of PLACEMENT_OPTIONS is passed as a JSON string with the context of the call.
For IM_SIDEBAR, the following key is passed in the context:
dialogId— the identifier of the current chat
OPTIONS when registering via placement.bind
For IM_SIDEBAR, the placement.bind method supports OPTIONS parameters.
Required parameters are marked with *
|
Parameter |
Description |
|
iconName* |
Label of the item in the interface. Up to 50 characters, Latin letters, spaces, and |
|
extranet |
Access in the extranet, default is Possible values:
|
|
context |
Display context, default is Possible values:
If |
|
role |
User role, default is Possible values:
|
|
color |
Icon color from the IM palette. Possible values:
|
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"PLACEMENT": "IM_SIDEBAR",
"HANDLER": "https://your-domain.com/widgets/im-sidebar-handler.php",
"TITLE": "My sidebar item",
"LANG_ALL": {
"de": {
"TITLE": "Mein Sidebar-Element"
},
"en": {
"TITLE": "My sidebar item"
}
},
"OPTIONS": {
"iconName": "chat-tools",
"context": "ALL",
"role": "USER",
"extranet": "N",
"color": "LIGHT_BLUE"
},
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/placement.bind
try
{
const response = await $b24.callMethod(
'placement.bind',
{
PLACEMENT: 'IM_SIDEBAR',
HANDLER: 'https://your-domain.com/widgets/im-sidebar-handler.php',
TITLE: 'My sidebar item',
LANG_ALL: {
de: {
TITLE: 'Mein Sidebar-Element',
},
en: {
TITLE: 'My sidebar item',
}
},
OPTIONS: {
iconName: 'chat-tools',
context: 'ALL',
role: 'USER',
extranet: 'N',
color: 'LIGHT_BLUE',
}
}
);
const result = response.getData().result;
if (result.error())
console.error(result.error());
else
console.info(result.data());
}
catch (error)
{
console.error('Error:', error);
}
try {
$response = $b24Service
->core
->call(
'placement.bind',
[
'PLACEMENT' => 'IM_SIDEBAR',
'HANDLER' => 'https://your-domain.com/widgets/im-sidebar-handler.php',
'TITLE' => 'My sidebar item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Sidebar-Element',
],
'en' => [
'TITLE' => 'My sidebar item',
],
],
'OPTIONS' => [
'iconName' => 'chat-tools',
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
'color' => 'LIGHT_BLUE',
],
]
);
$result = $response->getResponseData()->getResult();
if ($result->error()) {
error_log($result->error());
} else {
echo 'Success: ' . print_r($result->data(), true);
}
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error binding placement: ' . $e->getMessage();
}
BX24.callMethod(
'placement.bind',
{
PLACEMENT: 'IM_SIDEBAR',
HANDLER: 'https://your-domain.com/widgets/im-sidebar-handler.php',
TITLE: 'My sidebar item',
LANG_ALL: {
de: { TITLE: 'Mein Sidebar-Element' },
en: { TITLE: 'My sidebar item' }
},
OPTIONS: {
iconName: 'chat-tools',
context: 'ALL',
role: 'USER',
extranet: 'N',
color: 'LIGHT_BLUE'
}
},
function(result) {
if (result.error()) {
console.error(result.error());
} else {
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'placement.bind',
[
'PLACEMENT' => 'IM_SIDEBAR',
'HANDLER' => 'https://your-domain.com/widgets/im-sidebar-handler.php',
'TITLE' => 'My sidebar item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Sidebar-Element',
],
'en' => [
'TITLE' => 'My sidebar item',
],
],
'OPTIONS' => [
'iconName' => 'chat-tools',
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
'color' => 'LIGHT_BLUE',
],
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Continue Learning
- Set Up the Widget Handler placement.bind
- Interaction with UI from Widgets
- Interactive Applications
- Open a Slider with Your Interface
- Open Standard Bitrix24 Pages from Application Widgets