Adding notifications
To publish notifications, a public API is implemented, accessed through calling the corresponding methods of the global Kommo object APP. When you call the method, you need to transfer an object with a description of the notification.
Information Notice
The method is designed to trigger a pop-up notification, which will only appear in the interface and will not be duplicated on other delivery channels.
Method name
show_message()
Parameter | Required? | Description |
---|---|---|
header | β | Post Title |
text | β | Notification text |
date | β | Date in Unix Timestamp format |
icon | β | URL to an icon file. If not passed, then the default icon of robot is used. |
Example:
var message_params = {
header: "Warning",
text: "Connection established",
date: 1714566795,
icon: "https://www.example.com/images/telephone.png"
};
APP.notifications.show_message(message_params);
Result:
Error Notification
The method will show an error notification in the account interface, and the message will not be sent through other delivery channels.
Method name
show_message_error()
Parameters
Parameter | Required? | Description |
---|---|---|
header | β | Post Title |
text | β | Notification text |
date | β | Date in Unix Timestamp format |
link | β | The URL where a user will be redirected if they click the 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 enables you to show a pop-up notification for a call or an error. If you utilize this feature, it will only appear in the interface and will not be sent through other channels.
Method name
show_notification()
Parameters
Parameter | Required? | Description |
---|---|---|
text | β | Array with a description of the message |
text/header | β | Notification Header |
text/text | β | Text message |
date | β | Date in Unix Timestamp format |
type | β | Type of pop-up notification(call or error ) |
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 enables you to add an error notification to the notification center, and the message will be sent to all active channels in the userβs account.
Method name
add_error()
Parameters
Parameter | Required? | Description |
---|---|---|
header | β | Post Title |
text | β | Notification text |
date | β | Date in Unix Timestamp format |
link | β | The URL where a user will be redirected if they click the notification. |
Example
var error_params = {
header: "Error",
text: "Failed to set the task! Contact not found!",
date: 1714566795,
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 | β | The text message that will be displayed in the notification. |
date | β | Date in Unix Timestamp format |
from | β | he line specifies the initiator of the incoming call. It displays the phone number if it is not found in your contact list, and the contact name if the call came from a number in your contact list. |
to | β | Manager name or extension number of the subscriber who received the incoming call. |
element | β | An object describing the target entity for the transition when clicking the pop-up call notification. |
element.id | β | Entity ID |
element.type | β | Entity type: contact, lead or company |
link | β | A link to a recording of the call |
Parameter
var call_params = {
text: "Call from +1 (415) 523-7743",
date: 1714566795,
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);
Result
Updated 4 days ago