1

It looks like the init() function is asynchronous - is there any way to know when it finishes? Something like jQuery complete? For example

.getJSON('/blah', function(data) {
  /* Invoked when request finishes */
});

The problem that I'm facing is that if I call liveagent.startChat() immediately after liveagent.init() I get parse error inside deplyment.js script:

TypeError: l[a] is undefined
  ...on(){aa()};n.startChat=function(a,b,c){(b?K(a,b):l[a]).startChat("liveagent"+Mat...

deployment.js (line 63, col 336)

But if I wait a while before calling liveagent.startChat() then everything works fine.

  • There is no callback like getJSON has, however if you have a Start Chat button you can watch for it to go "online", at that point liveagent is finished loading. – ScottW Sep 16 '14 at 3:22
  • @ScottW Sorry for the late response but I did something similar and used hidden div to watch for 'online' status. If you'll turn your comment into an answer I'll be happy to accept it. – SiliconMind Jan 13 '15 at 11:39
2

Just in case someone else comes across this. We have an article that explains how to handle this

https://help.salesforce.com/apex/HTViewSolution?urlname=Live-Agent-Starting-a-chat-ends-with-a-404-page&language=en_US

Sample Code:

    <div id="chatonline" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573i0000000B238', document.getElementById('chatonline'));
});</script>

<script type='text/javascript' src='https://c.la1a1.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>

<script type='text/javascript'>

liveagent.addButtonEventHandler('573i0000000B238',function (e){
    if(e == liveagent.BUTTON_EVENT.BUTTON_AVAILABLE){              
            liveagent.startChatWithWindow('573i0000000B238','mywindowid');          
    }       
});
liveagent.init('https://c.la1a1.salesforceliveagent.com/chat', '572i0000000AybE', '00Di0000000jR2X');
</script>
  • Thanks @PeppeFloyd. I'm accepting this answer, however I said farewell to the salesforce chat months ago and suggest the same to anyone struggling with it. It's just not worth it. Use proper chat solutions like livechatinc.com and others - they can integrate with salesforce anyway. – SiliconMind Apr 22 '16 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.