Skip to content

Instantly share code, notes, and snippets.

@jfeliweb
Forked from peterknolle/preChat.html
Created June 3, 2014 16:06
Show Gist options
  • Save jfeliweb/1456ef425011d78c4e1a to your computer and use it in GitHub Desktop.
Save jfeliweb/1456ef425011d78c4e1a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
}
if (window.addEventListener) {
window.addEventListener('load', handlePageLoad, false);
} else {
window.attachEvent('onload', handlePageLoad, false);
}
})();
</script>
</head>
<body>
<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 />
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;" />
<!-- 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;" />
<!-- 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;" />
<!-- 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" />
<!-- 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;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />
<!-- 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="prechat_submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment