Adding notifications
To publish notifications, a public API is implemented, accessed through calling the corresponding methods of the global Kommo object. When you call the method, you need to transfer an object with a description of the notification.
Information Notice
The method is intended for calling a pop-up notification, which will be displayed to the user only in the interface and will not be replicated on other delivery channels.
Method name
show_message()
Parameters
Parameter | Required | Description |
---|---|---|
header | Yes | Post Title |
text | Yes | Notification text |
date | No | Date in timestamp format |
icon | No | URL to arbitrary icon file. If not passed, then the default icon of robot is used |
Example
var message_params = {
header: "Warning",
text: "Connection established",
date: +19534084500,
icon: "https://www.example.com/images/telephone.png"
};
APP.notifications.show_message(message_params);
Result
Error Notification
The method displays an error notification in the interface of the account, and the message will not be transmitted via other delivery channels.
Method name
show_message_error()
Parameters
Parameter | Required | Description |
---|---|---|
header | Yes | Post Title |
text | Yes | Notification text |
date | No | Date in timestamp format |
link | No | redirect URL when clicking on a notification |
Example
var error_params = {
header: “Warning”,
text: “Connection to the server is lost”
};
APP.notifications.show_message_error(error_params);
Result
Incoming call notification
The method allows you to display a pop-up notification of a call or an error. If you use this message, it will be displayed only in the interface and will not be transmitted through other channels.
Method name
show_notification()
Parameters
Parameter | Required | Description |
---|---|---|
text | Yes | Array with a description of the message |
text/header | Yes | Notification Header |
text/text | Yes | Text message |
date | No | Date in timestamp format |
type | Yes | Type of pop-up notification. Can take values call or type |
Example
var notification = {
text: {
header: "Outgoing call",
text: "Dialing the number +19872345678"
},
type: "call"
};
APP.notifications.show_notification(notification);
Result
Example
var notification = {
text: {
header: "Error",
text: "Error working with the widget"
},
type: "error"
};
APP.notifications.show_notification(notification);
Result
Adding an error notification
The method allows you to add an error notification to the notification center. The message will be sent to all active channels in the user’s account.
Method name
add_error()
Parameters
Parameter | Required | Description |
---|---|---|
header | No | Post Title |
text | Yes | Notification text |
date | No | Date in timestamp format |
link | No | The link that will trigger the click on the notification |
Example
var error_params = {
header: "Error",
text: "Failed to set the task! Contact not found!",
date: +19534085310,
link: "/contacts/list/?term=4951234567"
};
APP.notifications.add_error(error_params);
Result
An email notification about the error.
Notification that has come to the mobile application.
Incoming call notification
The Notification Center API allows you to display an incoming call message. The notification will be transmitted over all active delivery channels.
Method name
add_call()
Parameters
Parameter | Required | Description |
---|---|---|
text | Yes | The text message that will be displayed in the notification. |
date | No | Date in timestamp format |
from | No | The line in which the initiator of the incoming call is specified. Phone number – if the contact is not found in your account. Contact name – if the call came from an existing contact in your account. |
to | No | Manager name or extension number of the subscriber who received the incoming call. |
element | No | An object describing the entity to which the transition will occur when clicking on the pop-up call notification. |
element.id | Yes | Entity ID |
element.type | Yes | Entity type: contact, lead or company |
Parameter
var call_params = {
text: "Call from +1 (415) 523-7743",
date: +19534084500,
from: "Jeremy Watts",
to: "Jason Nash",
element: { id: 18221265, type: "contact" },
duration: 250,
link: 'https://example.com/dialog.mp3'
};
APP.notifications.add_call(call_params);