Widget Above the IM_TEXTAREA Input Field
Scope:
im
You can add your item to the panel above the message input field.
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 panel above the input field |
Where to Find It in the Interface
Open the chat and scroll to the bottom of the window where the message input field is located. In the bottom right corner of the input field, open the application panel. The application item with PLACEMENT=IM_TEXTAREA can be found in this panel.
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_TEXTAREA
[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_TEXTAREA, the following key is passed in the context:
dialogId— the identifier of the current chat
OPTIONS When Registering via placement.bind
For IM_TEXTAREA, 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:
|
|
width |
Width of the block in percentage, default is |
|
height |
Height of the block in percentage, default is |
Code Examples
How to Use Examples in Documentation
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"PLACEMENT": "IM_TEXTAREA",
"HANDLER": "https://your-domain.com/widgets/im-textarea-handler.php",
"TITLE": "My toolbar item",
"LANG_ALL": {
"de": {
"TITLE": "Mein Toolbar-Element"
},
"en": {
"TITLE": "My toolbar item"
}
},
"OPTIONS": {
"iconName": "chat-compose",
"context": "ALL",
"role": "USER",
"extranet": "N",
"color": "LIGHT_BLUE",
"width": 100,
"height": 100
},
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/placement.bind
try
{
const response = await $b24.callMethod(
'placement.bind',
{
PLACEMENT: 'IM_TEXTAREA',
HANDLER: 'https://your-domain.com/widgets/im-textarea-handler.php',
TITLE: 'My toolbar item',
LANG_ALL: {
de: {
TITLE: 'Mein Toolbar-Element',
},
en: {
TITLE: 'My toolbar item',
}
},
OPTIONS: {
iconName: 'chat-compose',
context: 'ALL',
role: 'USER',
extranet: 'N',
color: 'LIGHT_BLUE',
width: 100,
height: 100,
}
}
);
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_TEXTAREA',
'HANDLER' => 'https://your-domain.com/widgets/im-textarea-handler.php',
'TITLE' => 'My toolbar item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Toolbar-Element',
],
'en' => [
'TITLE' => 'My toolbar item',
],
],
'OPTIONS' => [
'iconName' => 'chat-compose',
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
'color' => 'LIGHT_BLUE',
'width' => 100,
'height' => 100,
],
]
);
$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_TEXTAREA',
HANDLER: 'https://your-domain.com/widgets/im-textarea-handler.php',
TITLE: 'My toolbar item',
LANG_ALL: {
de: { TITLE: 'Mein Toolbar-Element' },
en: { TITLE: 'My toolbar item' }
},
OPTIONS: {
iconName: 'chat-compose',
context: 'ALL',
role: 'USER',
extranet: 'N',
color: 'LIGHT_BLUE',
width: 100,
height: 100
}
},
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_TEXTAREA',
'HANDLER' => 'https://your-domain.com/widgets/im-textarea-handler.php',
'TITLE' => 'My toolbar item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Toolbar-Element',
],
'en' => [
'TITLE' => 'My toolbar item',
],
],
'OPTIONS' => [
'iconName' => 'chat-compose',
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
'color' => 'LIGHT_BLUE',
'width' => 100,
'height' => 100,
],
]
);
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