8

Here are some related links:

  1. Custom Pre-Chat Component Sample Using Aura
  2. Custom Pre-Chat Component Sample Using JavaScript
  3. Find and Create Records Pre-Chat API Code Sample

Based on link 3, it seems like if we were using a Visualforce Page for our Prechat form, we would be able to upsert a single Contact record, in order to associate the LiveChatTranscript to an existing record. However, I'm having a hard time hunting down how that would be done using a custom Lightning Component hooked up to a Snap-in, as described in link 1.

We're trying to do the association based on a Unique External Id field. When an existing value is populated in the Prechat form, no Contact record is created nor associated to the LiveChatTranscript. When a new value is populated, a new Contact is created and associated. The behavior observed so far seems to indicate any DML failures are silent, and the transcript record can be created regardless of any failures up to that point.

I can't find any documentation on the Prechat API surfaced via the lightningsnapin:prechatAPI component. It doesn't seem to have any sort of analogue to the findOrCreate map that would have allowed us to upsert in classic.

Is it possible to have a Lightning Prechat Snap-in upsert a Contact record based on a Unique External Id field included in the prechat form? If so, how?

  • I know you're trying to use the API in #3, have you considered using a server side controller for your snap-in? I don't know if they work like Lightning Components or not (from the code, it appears like they do), but that might provide a work-around. – crmprogdev Jul 22 '18 at 12:58
  • Is there an Apex API for Prechat? – Adrian Larson Jul 23 '18 at 1:10
  • Adrian, I've never worked with the LiveAgent API. I simply saw the similarity to Lightning Components in the links you provided and that's why I made the suggestion. I do know there's also a LiveAgent REST API that might also offer some some means of providing a workaround for this issue. I'm assuming your real issue is related to the new Lightning Console and you may want to consider filing a case on this as a possible bug or parity discrepancy. Use the access you now have. ;) – crmprogdev Jul 23 '18 at 11:44
2
+250

The Snap-Ins for Web Developer Guide contains this page:

Pre-Chat Code Examples

Find contacts but don't create new ones

In this example, we don't want to create contact records — we only want to find them. To disable creation of a record, set doCreate to false for all the required fields for the record. This code disables a common default behavior of creating a contact record with each chat session.

 embedded_svc.settings.extraPrechatInfo = [{
   "entityFieldMaps": [{
     "doCreate":false,
     "doFind":true,
     "fieldName":"LastName",
     "isExactMatch":true,
     "label":"Last Name"
   }, {
     "doCreate":false,
     "doFind":true,
     "fieldName":"FirstName",
     "isExactMatch":true,
     "label":"First Name"
   }, {
     "doCreate":false,
     "doFind":true,
     "fieldName":"Email",
     "isExactMatch":true,
     "label":"Email"
   }],
   "entityName":"Contact"
 }];
  • This solution is only available for the Snap-Ins using the JavaScript implementation, so this is not available if implementing a Snap-Ins prechat form in Lightning, which is limited to what you can do with the lightningsnapin:prechatAPI (which is very limited). – friendoflore Sep 18 '18 at 18:14

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.