function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KevinG514KevinG514 

OpenCTI callback not being called

I just completed an integration using the OpenCTI.  Things work fine on my dev machine, fine on another developers machine, and fine on a test machine i had setup about a month ago.  The strange thing is that i just setup a new test machine so i could finish dev testing and now it is appearing that the remote calls through the api are not working.  So the first thing my integration does is check if it is in the console and then check the call center settings.  When i step into interaction.js for one of those, it appears that the post message to the host salesforce page is working as expected.  I don't know what is happening on the other end of the post message because the js is minimized to a huge pain to debug.  The callbacks that i set in my code aren't being called.  Also, when testing with the screenpop method, the screenpop never happens either, so it seems that the listener for the post messages isn't getting them.

 

To take out the possibility that my code is causing a problem, i went back to a test page i wrote which makes simple calls like in the examples of the api.  I have the same results.

 

Has anyone else run into this?  I find it strange that it works on my dev machine, but not a production machine.  

Best Answer chosen by Admin (Salesforce Developers) 
KevinG514KevinG514

I figured it out.  There is a firefox plugin that will deminimize the javascript which allowed me to debug InteractionFramework.js

 

(https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/)

 

in the processPostMessage method in InteractionFramework.js there is a security check to verify the origin

 
if (a.origin !== Sfdc.interaction.sofphoneEventOriginUrl) Sfdc.interaction.doPostMessage(null, null, LC.getLabel("InteractionApi", "InvalidSoftphoneIframeOrigin")); 
 
when i setup the cti, i was using http://server:80/client so softphoneEventOriginUrl returned http://server:80, but a.origin was http://server/client, which makes sense.  removing the :80 from my config fixed my issues.
 
I didn't run into this on my dev machine because i run it on a different port.  

 

All Answers

KevinG514KevinG514

I figured it out.  There is a firefox plugin that will deminimize the javascript which allowed me to debug InteractionFramework.js

 

(https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/)

 

in the processPostMessage method in InteractionFramework.js there is a security check to verify the origin

 
if (a.origin !== Sfdc.interaction.sofphoneEventOriginUrl) Sfdc.interaction.doPostMessage(null, null, LC.getLabel("InteractionApi", "InvalidSoftphoneIframeOrigin")); 
 
when i setup the cti, i was using http://server:80/client so softphoneEventOriginUrl returned http://server:80, but a.origin was http://server/client, which makes sense.  removing the :80 from my config fixed my issues.
 
I didn't run into this on my dev machine because i run it on a different port.  

 

This was selected as the best answer
littleTigerlittleTiger

thanks very help ful, now I have discovered that

 

origin = "https://c.na15.visual.force.com" String

and
sofphoneEventOriginUrl = "https://na15.salesforce.com" String

 

but how can I make them equal?

littleTigerlittleTiger

to test I edited the value in IE's debugger so that they were the same, my call back happened right away. But obviously that is not a production fix :)

littleTigerlittleTiger

so I edited the call center definition to read:

https://c.na15.visual.force.com/apex/demoCallControl

for CTI Adapter URL, and it works, but is that really the fix? 

KevinG514KevinG514

Yeah, i think it is really the fix

gbu.varungbu.varun

Hi Kevin,

 

 

I am implementing Open CTI. I created Softphone and a HTML file. Can you please tell me when someone call to CTI how will salesforce know that a call has been reached on CTI. Please help me.

KevinG514KevinG514

OpenCTI is one of the few cti apis that doesn't care about about when an agent is on a call or what the state of the call is.   That leave it up to the integrator to do the legwork on how to present the call to the agent.  

 

(a good design choice in my opinion)  

jasmin menezesjasmin menezes
(OpenCTI callback not being called when two level loadbalancer used)

Hi Kevin,

When the two level load balancer used, say "agent.xyz.com" which will redirect to either "agent1.xyz.com" or "agent2.xyz.com" using round robin fashion. So "agent.xyz.com" is the first level loadbalancer url which is configured and say it is redirected to "agent1.xyz.com" so the window origin will be "agent1.xyz.com". 
We have a method "processPostMessage" in InteractionFramework.js there is a security check to verify the origin.

if (a.origin !== Sfdc.interaction.sofphoneEventOriginUrl) Sfdc.interaction.doPostMessage(null, null, LC.getLabel("InteractionApi", "InvalidSoftphoneIframeOrigin")); 

Since a.origin is "agent1.xyz.com" and sofphoneEventOriginUrl is "agent.xyz.com" the security check conditon fails . Hence we are unable to hit the saleforce api's. Since it is a load balancer we cant change the url's manually. Is there any other work arround to fix this.  Please help. 

Thanks in advance .