Click to call

Kommo enables managers to perform calls from any card, whether it’s contact, company, lead or customer, by clicking on the phone number in the card.

foto

This feature is implemented by the ready-made add_action( type, action) function.

Parameters

Parameter Description
type The type of the passed parameter, for phone calls “phone”
action The function that will be called when clicking on a phone number

Example about using the add_action() function by placing it in the init callback function. Callbacks are part of the script.js structure.

/* script.js */
init: function(){
 /*
 * 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');
  }
  );
 });
}

It is important to remember that you must declare the widget’s scope in manifest.json. To execute the add_action() function, you need to set scopes where phone numbers are displayed. Read more about connection areas.

The following example specifies all connection areas where you can find phone numbers.

/* manifest.json */
{
	...

	"locations":[
		"ccard-1",
		"clist-1",
		"lcard-1",
		"llist-1",
		"cucard-1",
		"culist-1",
		"comcard-1"
	]

	...
}

In order to change the description when clicking on the phone number, you need to make the appropriate changes in the *.json localization files in the i18n directory of your widget structure, as shown in the example below. If the “call_action” parameter is not set, the label on the button will be set by default to the name of your widget, which is a required parameter in manifest.json. The “call_action” value will be set to the button automatically when the widget is initialized.

Example (json file)

/* en.json */
{
	"widget": {
		"call_action": "Call"
	}
}

/* es.json */
{
	"widget": {
		"call_action": "Llamada"
	}
}