Print this page

PreChat API Fails when using Live Agent API and Custom Chat Windows

Knowledge Article Number 000193576
Description When developing a custom VF chat window the prechat API invoked by the prechat form stops working.

For example in your pre-chat form you may have calls to the prechat API to create a case record when a call comes in such as:
<input type='hidden' name='liveagent.prechat:caseorigin' value='Chat'/>
<input type='hidden' name='liveagent.prechat:caseContactId' value='{!$User.ContactId}'/>
<input type="hidden" name="" value="Origin,caseorigin;ContactId,caseContactId;" />
<input type="hidden" name="" value="Origin,true;ContactId,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

When your custom chat window loads, you will notice the above pre-chat api calls from the pre chat form do not get invoked. 

This occurs when a custom chat page is selected on a Chat Button's config page, this URL changes. 
- It changes from a domain to the site domain used to host the pre-chat and custom chat pages. 
- This means the HTTP POST containing the custom detail form data is sent to a different end-point, and has a different response. 
- The response from the POST to the domain does not contain some chasitor methods that maps custom details to SOBject fields

Known Issue:

Resolution On the custom chat page (that is, the Visualforce page that uses the <liveagent:~> tags), add in the missing chasitor methods: 

In the case of the specific example provided in this article (creating cases), it would look like this within <script> tags in your custom VF chat page:

liveagent.chasitor.addEntity('Case', 'true', null, null, 'Case'); 
liveagent.chasitor.addEntityFieldsMap('Case', 'Origin', 'caseorigin', 'false', 'false', 'true'); 
liveagent.chasitor.addEntityFieldsMap('Case', 'ContactId', 'caseContactId', 'true', 'true', 'true'); 

promote demote