I've a requirement is,When the Visitor fills in the prechat form with some basic stuff like First Name, Last Name, Email, Case Number,then "I'm trying to find that Case if not found create a new Case or display the existing Case and Search Contact,if not found create new Contact or display the existing Contact.

I followed one link http://peterknolle.com/live-agent-pre-chat-api/ ,but here explained about Create a Case every time,but I do search for existing case or create new one if not exist then link to contact.

Please help me in this regards

2 Answers 2


Use the doFind method, see the usage in the Live Agent Developer Guide



Use these lines at proper places.

If the end user enters the case number in the form then it will not create a new case but searches and displays the case the user entered and the related contact based in email id.

If the end user doesn't enter the case number then it will automatically create the case and attaches to the contact.

 <form method="post" id="prechatForm">

<!-- Detail inputs -->
First Name: <input type="text" name="liveagent.prechat:contactFirstName" /><br />
Last Name: <input type="text" name="liveagent.prechat:contactLastName" /><br />
Email: <input type="text" name="liveagent.prechat:contactEmail" /><br />
Case Number: <input type="text" name="liveagent.prechat:caseNumber" /><br />
Subject: <input type="text" name="liveagent.prechat:caseSubject" /><br />

<!-- Map the detail inputs to the Contact fields -->
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="FirstName,contactFirstName;LastName,contactLastName;Email,contactEmail;" />

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;CaseNumber,caseNumber;" />

<!--<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="CaseNumber,caseNumber;" />-->

<!-- Try to find the Contact by email (exact match) -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="Email,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Case" value="CaseNumber,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Case" value="CaseNumber,true;" />

<!-- If the Contact is not found, then create one with the following fields set -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="FirstName,true;LastName,true;Email,true;" />

<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;" />

<!-- Save the Contact on the Live Chat Transcript's Contact Loookup -->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="Contact" />

<!-- Show the Contact when it is found or created -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

<!-- Create a Case every time -->
<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />
<!--<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;CaseNumber,caseNumber;" />-->
<!--<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;CaseNumber,true" />-->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
<!--<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />-->
<input type="hidden" name="liveagent.prechat.save:Case" value="Case" /> 
<!-- <input type="hidden" name="liveagent.prechat.save:Case" value="Case" /> -->

<!-- Link the Contact to the Case -->
<input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId;" />

<input type="submit" value="Request Chat" id="prechatForm" />

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.