1

After customer registers his case and automated email is sent to him. In this email there should be an hyperlink - which initiates the live chat with available agent. From agent side- when he accepts the chat- he needs to get the existing case record window on his screen. This is the requirement. I'm trying to put the button and deployment code in the HTML email Template. But it is not working. Someone please help me to resolve this issue.

Below is the code that I'm trying to use in the email template.

<!-- Button Code -->
<a id="liveagent_button_online_582f000000000RK" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('582f000000000RK')" > CLick Here</a> 
<div id="liveagent_button_offline_582f000000000RK" style="display: none;"> Sorry No Agent Available </div>
<script type="text/javascript">
if (!window._laq) { window._laq = []; } 
 window._laq.push(function(){liveagent.showWhenOnline('582f000000000RK', document.getElementById('liveagent_button_online_582f000000000RK'));
 liveagent.showWhenOffline('582f000000000RK', document.getElementById('liveagent_button_offline_582f000000000RK'));})
</script>


<-- Deployment Code -->
<script type='text/javascript' src='https://c.la4-c8ch-iad.salesforceliveagent.com/content/g/js/40.0/deployment.js'></script>
<script type='text/javascript'>

<!-- liveagent.addCustomDetail('Case Number', '00001006');  -->

liveagent.addCustomDetail('Case Number', '{!Case.caseNumber}'); 

liveagent.findOrCreate('Case').map('CaseNumber','Case Number',true,true,true).saveToTranscript('CaseId').showOnCreate();

liveagent.init('https://d.la4-c8ch-iad.salesforceliveagent.com/chat', '582c0000000Cpya', '00Dk0000009w6Y7');

</script>
1

So the case is already created in salesforce and we need to send an email.

Please create a HTML email with the content you require in mail and live chat html, javascript content with below sample as reference(example is self-explanatory) : https://developer.salesforce.com/docs/atlas.en-us.live_agent_dev.meta/live_agent_dev/live_agent_deployment_api_code_sample.htm

You would need to findOrCreate a case record using Case Number with true, true, true as parameters(Use Case Number or any unique information you have captured during case creation instead of Status in below sample)

liveagent.findOrCreate('Case')..map('Status','Case Status',false,false,true).saveToTranscript('CaseId').showOnCreate();

This would facilitate the already created case to show up, get linked to transcript when a chat is initiated from the link in the email.

  • Thanks Wilson. The existing case is getting popup by passing the CaseNumber value manually. But how to pass the caseNumber value directly from email Template ? – S R Aug 19 '17 at 22:47
  • Welcome! Have you tried using merge field syntax for the Case Number variable in email template(where you are referencing it manually)? – Wilson Aug 20 '17 at 6:23
  • I just tried by pasting the code of a Chat button into an email template and it doesn't seem to work. – S R Aug 20 '17 at 17:06

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.