IM_CONTEXT_MENU Message Context Menu Item
Scope:
im
You can add your item to the context menu of messages in the chat.
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 |
|
|
Message context menu item |
Where to Find It in the Interface
Open any chat and hover over a message. In the message action bar, click the ... button to open the context menu. Hover over More to reveal additional menu items. The application item with PLACEMENT=IM_CONTEXT_MENU will appear at the end of the action list above the message.
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_CONTEXT_MENU
[PLACEMENT_OPTIONS] => {"messageId":84889, "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 containing the context of the call.
For IM_CONTEXT_MENU, the context includes the following keys:
dialogId— the identifier of the current chatmessageId— the identifier of the selected message
OPTIONS When Registering via placement.bind
For IM_CONTEXT_MENU, the placement.bind method supports OPTIONS parameters.
|
Parameter |
Description |
|
extranet |
Access in the extranet, default is Possible values:
|
|
context |
Display context, default is Possible values:
If |
|
role |
User role, default is 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_CONTEXT_MENU",
"HANDLER": "https://your-domain.com/widgets/im-context-menu-handler.php",
"TITLE": "My menu item",
"LANG_ALL": {
"de": {
"TITLE": "Mein Menüpunkt"
},
"en": {
"TITLE": "My menu item"
}
},
"OPTIONS": {
"context": "ALL",
"role": "USER",
"extranet": "N"
},
"auth": "**put_access_token_here**"
}' \
https://**put_your_bitrix24_address**/rest/placement.bind
try
{
const response = await $b24.callMethod(
'placement.bind',
{
PLACEMENT: 'IM_CONTEXT_MENU',
HANDLER: 'https://your-domain.com/widgets/im-context-menu-handler.php',
TITLE: 'My menu item',
LANG_ALL: {
de: {
TITLE: 'Mein Menüpunkt',
},
en: {
TITLE: 'My menu item',
}
},
OPTIONS: {
context: 'ALL',
role: 'USER',
extranet: 'N',
}
}
);
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_CONTEXT_MENU',
'HANDLER' => 'https://your-domain.com/widgets/im-context-menu-handler.php',
'TITLE' => 'My menu item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Menüpunkt',
],
'en' => [
'TITLE' => 'My menu item',
],
],
'OPTIONS' => [
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
],
]
);
$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_CONTEXT_MENU',
HANDLER: 'https://your-domain.com/widgets/im-context-menu-handler.php',
TITLE: 'My menu item',
LANG_ALL: {
de: { TITLE: 'Mein Menüpunkt' },
en: { TITLE: 'My menu item' }
},
OPTIONS: {
context: 'ALL',
role: 'USER',
extranet: 'N'
}
},
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_CONTEXT_MENU',
'HANDLER' => 'https://your-domain.com/widgets/im-context-menu-handler.php',
'TITLE' => 'My menu item',
'LANG_ALL' => [
'de' => [
'TITLE' => 'Mein Menüpunkt',
],
'en' => [
'TITLE' => 'My menu item',
],
],
'OPTIONS' => [
'context' => 'ALL',
'role' => 'USER',
'extranet' => 'N',
],
]
);
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