Print this page

Live Agent - Starting a chat ends with a 404 page

Knowledge Article Number 000233633
You may come across an scenario in which starting a chat results in the chat window presenting a 404 message and a URL that looks like the URL below   - Notice the endpoint=null query string

You may also see any of the following messages in the browser console:

"Failed to load resource: the server responded with a status of 404"

In more recent versions of the Live Agent deployment.js file you may see:

"You cannot call liveagent.startChat until the asynchronous call to liveagent.init has completed!" 


We have seen Live Agent implementations making use of JavaScript timed functions to call the StartChat or StartChatWithWindow methods after x amount of milliseconds after the 
page has loaded. This approach can cause the error described as it is not safe since there is no guarantee the init method has completed by the time startChat is called. 

A better approach is to add an event handler and invoke the startChat methods from there, see sample code below:

NOTE: The code  below is intended for illustration only.

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

<script type='text/javascript' src=''></script>

<script type='text/javascript'>
liveagent.addButtonEventHandler('573i0000000B238',function (e){
	if(e == liveagent.BUTTON_EVENT.BUTTON_AVAILABLE){			   
liveagent.init('', '572i0000000AybE', '00Di0000000jR2X');

promote demote