Failed to process API response. Interaction.js Salesforce

I’m using Twilio-Salesforce API to generate outbound calls, I’ve activated ClickToDial in my visualforce, but when I’m clicking the call button I’m receiving ‘Failed to process API response’ error message.

Error Message

and this is my javascript code:

javascript code

Any one have idea why this error is fired?

Answer

I just added the cleanFormatting function that is invoked from startCall function, here the three functions tht I’m using:

        sforce.interaction.cti.onClickToDial(startCall);//Invoke startCallFunction


        /*********************************
            Start a call to salesforce
        **********************************/
        function startCall(response) {    

            sforce.interaction.setVisible(true);  //pop up CTI console
            var result = JSON.parse(response.result);  
            var cleanednumber = cleanFormatting(result.number);             
            params = {"PhoneNumber": cleanednumber};
            Twilio.Device.connect(params);

        }

        /*********************************
               Clean Formating
        **********************************/
        function cleanFormatting(number) { 
              //changes a SFDC formatted US number, which would be 415-555-1212  into a twilio understanble number 4155551212      
             return number.replace(' ','').replace('-','').replace('(','').replace(')','').replace('+','');
        }   

I hope it helps.

Attribution
Source : Link , Question Author : Edgar , Answer Author : Edgar

Leave a Comment