2

I'm trying to push some custom data to the chat console from pre chat from but without success. I've tried hidden form elements like this:

<input type="hidden" name="liveagent.prechat:Username" value="Anonymous" />

And also tried JavaScript API

liveagent.addCustomDetail('Username', "Anonymous", true);

But the agent sees only most recently viewed pages when hovering over "Accept" chat button. Also no custom variables are displayed after chat is initialized.

The pre-chat form is embedded on a client site. To submit the form I just use this code:

<a href="javascript://Chat" onClick="liveagent.startChat('XXXX')">START CHAT</a>

How can I debug this? What is the correct way to pass this custom data?

1

You are using the deployment API which is different to the tags that must be used in the pre-chat form.

Here is an example on how to create a case with some information pre-populated that will also show in the console for the agent, you can do the same without creating a record, this should give you an idea.

<input type='hidden' name='liveagent.prechat:caseorigin' value='Chat'/>
<input type='hidden' name='liveagent.prechat:caseContactId' value='{!$User.ContactId}'/>
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseorigin;ContactId,caseContactId;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;ContactId,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

The section you care about if all you want is to show the details on the console would be this

<input type='hidden' name='liveagent.prechat:caseContactId' value='{!$User.ContactId}'/>

in combination with this value

<input type= "hidden" name= "liveagent.prechat.findorcreate.displayToAgent:caseContactId" value= "true" />

With that, you are assigning a value to a custom chat detail that will be shown to the agent that gets the chat assigned.

  • But all I want to do is to push some custom data that does not exists in salesforce and if I do something like this: <input type="hidden" name="liveagent.prechat:Balance" value="123" /> I don't get anything in the console. – SiliconMind Sep 15 '14 at 10:58
  • I have updated the answer, if you are not finding or creating you need to also use the displayToAgent method. – PepeFloyd Sep 15 '14 at 11:09
  • But what you wrote (two hidden input fields liveagent.prechat:caseContactId and liveagent.prechat.findorcreate.displayToAgent:caseContactId) is essentially the same as using JavaScript API and calling liveagent.addCustomDetail('Username', "Anonymous", true);, right? At least that's what I've found in the docs. The problem is that neither of those works for me. My console does not get any additional data. – SiliconMind Sep 15 '14 at 12:13
  • They do the same but in a different way. I have successfully used the deployment API method as well. Can you post the entire relevant code? – PepeFloyd Sep 15 '14 at 12:55
  • I've inherited some gibberish code from other dev and I'm now trying to clean it up. My eyes hurt when I stare at it if you know what I mean :) The weird thing is that after some tweaking to the code I was able make this work only with JavaScript API, but HTML with those hidden elements still doesn't work. Unfortunately these changes caused another issue with liveagent.init() – SiliconMind Sep 15 '14 at 13:08

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.