As per Freshsales cti documentation, click to call capability is provided by calling events api.
The calling event should be triggered only once for a single click on a number but for a single click, the number of received calling event in the app is more than once, and sometimes the number of events received is as high as 5 times for a single click.
CODE -
client.events.on(“calling”, handlec2cevent);
function handlec2cevent(data) {
console.info(“c2c initiated for”, data);
}
OUTPUT on console-
c2c initiated for {targetableType: “lead”, targetableId: “4015911390”, phoneNumber: “+917411162213”}
c2c initiated for {targetableType: “lead”, targetableId: “4015911390”, phoneNumber: “+917411162213”}
Also, see the attached image for the same Freshsales_calling.png
@gourav.kumar, Thank you for mentioning the required code and details. Those were helpuful. Please allow me sometime to have it checked with Freshsales team and get back to you.
Looking at the above code, it is clear that as soon as app is initialized there are two event listeners attached to it. One is on "app.activated" and other one is "calling".
(Assumption) This meant that when product prepares itself to open up the api, by then app is initialized and the call back is registered but not fired.
As soon as app is activated, and User clicks on the phone number within the page, the callback handlec2cevent is registered and fired. Since the call stack already has the previous invocation also in the stack, led to call back method executing twice.
Fix
Our fix was simple, We moved the "calling" event listener under "app.activated" to avoid this.
var client;
$(document).ready(function () {
app.initialized().then(function (_client) {
client = _client;
client.events.on("app.activated", function () {
client.events.on("calling", handlec2cevent);
});
});
});
function openModal() {
client.interface.trigger("showModal", {
title: "Add Integration Action",
template: "modal.html",
});
}
function closePopup() {
client.instance.close();
}
function handlec2cevent(event) {
console.log("c2c triggered", event);
}