Click-to-call
Kommo allows managers to make calls from any contact, company, or lead card by simply clicking on the phone number in the card.
This functionality is implemented using the add_action(type, action) function:
| Parameter | Data type | Description |
|---|---|---|
type | string | The type of the passed parameter (email or phone) |
action | function | The function that will be called when clicking on a phone number or email address |
For example, you can use the add_action(type, action) function by placing it in the init callback function, which is a part of the script.js structure.
init: function(self){
/*
* add call_to action
* type: phone
* Value of field phone
*/
self.add_action('phone', function(data){
self.crm_post (
/* Send the request to your voip service
* to perform dialing the number
* The method crm_post (url, data, callback, type, error)
*/
'http://yourservice.com/dealmethod.php',
{
call_to: data.value
},
function(msg){
alert('Call is performed');
},
'text',
function(){
alert ('Error');
}
);
});
}You need to declare the widget locations in the manifest.json in order to execute the
add_action(type, action)function. You must set those locations where phone numbers are displayed
The following example specifies all the widget locations where phone numbers can be found
{
...
"locations": [
"ccard-1",
"clist-1",
"lcard-1",
"llist-1",
"comcard-1",
"everywhere"
],
...
}If you want to change the label on the button that appears when you click on a phone number or email address, you will need to make the necessary changes in the .json localization file located in the i18n directory of your widget structure.
i18n files
{
"widget": {
"call_action": "Call"
}
}{
"widget": {
"call_action": "Llamar"
}
}{
"widget": {
"call_action": "Chamar"
}
}If the call_action parameter is not specified, the button label will default to the name of your widget, which is a required parameter in manifest.json. The value of call_action" will be automatically inserted into the button when the widget is initialized.
Updated about 8 hours ago