0

This question is a follow-on to my previous question: LiveAgent Chat with External ID

I am trying to pass in a Contact external ID from a non-Salesforce web page and use that to look up the Contact and display its name in the Live Agent window. Specifically, the Live Agent's chat window in Salesforce, not the client.

I am using the Live Agent deployment API which is the JavaScript-based API that sets up the chat from the client end and makes the connection to Salesforce.

Below is the JavaScript code which looks up the Contact record, maps the external ID, and initializes the chat. What is missing is "get the Name field from the Contact." I know I can use liveagent.setName() to put a string in the Live Agent window, but I need help getting the name from the contact first so I can marshal that value into the next API call.

    <script type="text/javascript">
var extId = ...;
liveagent.addCustomDetail('External_ID__c', extId);
liveagent.findOrCreate('Contact').map('External_ID__c', 'External ID', true, true, false);
/* I need to get the Contact.Name field from the Contact record here */
liveagent.setName('???');
liveagent.init('https://XXXXXXX.salesforceliveagent.com/chat', 'XXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXX');
    </script>
5
  • I recommend the following resources Visualforce Workbook and the Visualforce Developer’s Guide. I'd especially recommend you look at How do I start to debug my own VF javascript.
    – crmprogdev
    Commented Oct 16, 2014 at 14:36
  • This is not VisualForce. This is a regular HTML web page and will not be hosted in Salesforce.
    – user6861
    Commented Oct 16, 2014 at 14:43
  • So you're just asking for help with debugging the javascript you've written or what's the specific issue you're having? No offense intended, but if it's simply an issue of coding/debugging the HTML/javascript, it would be considered outside the scope of this forum. See help on-topic
    – crmprogdev
    Commented Oct 16, 2014 at 14:50
  • @crmprogdev what I am asking is in the second paragraph of the question: "I am trying to pass in a Contact external ID from a non-Salesforce web page and use that to look up the Contact and display its name in the Live Agent window. Specifically, the Live Agent's chat window in Salesforce, not the client." I am using a Salesforce API for LiveAgent integration, so I am unsure why this would be off-topic here.
    – user6861
    Commented Oct 16, 2014 at 14:55
  • I take it your page/pop-up applet displays properly except that you're unable to retrieve the Contact? If that's the case, it would appear you're either asking how to run a query to Salesforce based on passing External_ID__c into the page by creating a JS function to do that, or else how to configure a controller of some kind to return the Contact using External_ID__c as the input. Would that be the essence of what you're asking? If so, you may want to edit your question to clarify it.
    – crmprogdev
    Commented Oct 16, 2014 at 18:14

1 Answer 1

1

You are mixing up two different things. LiveAgent has different APIs depending on how the chat is being launched.

The tags that you see used on HTML INPUT elements are using the Pre-Chat API which must be used in a pre-chat form, which is the form that is used to collect information from the client prior to submitting it to Salesforce. You can see its usage on the section "Pre-Chat Form Code Sample" in the Live Agent Developer Guide.

The other syntax you are using must be used when you want to pass information directly from the page that contains the button, this is normally information that the user did not enter in a form, this API is referred to as the Deployment API. You can see its usage in the guide in the section "Deployment API Code Sample"

In your case, I believe you should just be using the deployment API.

3
  • 1
    Thank you, this looks promising. I have never used Live Agent until a week ago, and it seems like everyone who posts code samples are using the pre-chat API which my customer does not want to do. That should explain my confusion, but this helped sort it out. Once I have this working I will accept your answer.
    – user6861
    Commented Oct 17, 2014 at 13:24
  • I have been reviewing the deployment API documentation and looking at the code samples, but there is still one piece missing: getting the value of Contact.Name so I can call liveagent.setName() with that value. I updated my question to be a bit more concise and focused on this specific issue.
    – user6861
    Commented Oct 17, 2014 at 14:44
  • Turns out that what I need is not possible, but I misunderstood the requirement to begin with. This answer is about as close as it gets though.
    – user6861
    Commented Oct 17, 2014 at 16:48

You must log in to answer this question.