Find and Create Records Pre-Chat API Code Sample

Test and preview how to automatically create records when a customer completes a pre-chat form using this code sample.

The following code searches for and creates records when a customer completes a pre-chat form using the following methods:

  • findOrCreate.map
  • findOrCreate.map.doFind
  • findOrCreate.map.isExactMatch
  • findOrCreate.map.doCreate
  • findOrCreate.saveToTranscript
  • findOrCreate.showOnCreate
  • findOrCreate.linkToEntity
1<form method="post" action="#">
2<label>First Name: </label> <input type='text' name='liveagent.prechat:ContactFirstName' /><br />
3<label>Last Name: </label> <input type='text' name='liveagent.prechat:ContactLastName' /><br />
4<label>Subject: </label> <input type='text' name='liveagent.prechat:CaseSubject' /><br />
5<input type="hidden" name="liveagent.prechat:CaseStatus" value="New" /><br />
6<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="FirstName,ContactFirstName;LastName,ContactLastName" />
7<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="FirstName,true;LastName,true" />
8<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="FirstName,true;LastName,true" />
9<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="FirstName,true;LastName,true" />
10<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="ContactId" />
11<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />
12<input type="hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />
13<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Subject,CaseSubject;Status,CaseStatus" />
14<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Subject,true;Status,true" />
15<input type="submit" value="Submit" />
16</form>