Here are some related links:
- Custom Pre-Chat Component Sample Using Aura
- Custom Pre-Chat Component Sample Using JavaScript
- 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?
Best Answer
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.