Receiving Freshsales calling event more than once for a single click

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.

Hi,
Any update here?

Freshsales team is still looking into this @gourav.kumar. I am actively following up them.

I am trying to reproduce the issue @gourav.kumar.

I don’t see any image attached to the post. Maybe somehow missed it? Can you please add it?

Hi,
I have uploaded the image

I have initiated a private message with you @gourav.kumar. Can you please check your Messages section of this forum and respond ?

Summary for the followers of this thread

When issue was reported, app client side javascript looked like this,

var client;
$(document).ready( function() {
    app.initialized()
        .then(function(_client) {
            client = _client; // FOCUS SECTION START
            client.events.on("app.activated",
                function() {
                    // LOGIC
                });
            client.events.on("calling", handlec2cevent);
            function handlec2cevent(event){
              console.log("c2c triggered", event);
            }
// FOCUS SECTION END
        });
});

function openModal() {
    client.interface.trigger('showModal', {title: 'Add Integration Action', template: 'modal.html'});
}

function closePopup() {
    client.instance.close();
}
  1. 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".
  2. (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.
  3. 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);
}

1 Like