Created
January 25, 2014 23:15
-
-
Save peterknolle/8625272 to your computer and use it in GitHub Desktop.
Live Agent Pre-Chat API in Pre-Chat Form for Service Cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This is really interesting, and for myself it helped me use more efficiently the Live Agent prechat API.
Thanks !!!
Awesome work Peter! planning to use it for our Org!Appreciated all your efforts!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is code from my blog article here: http://peterknolle.com/live-agent-pre-chat-api/.