Contact and Case records created from Pre-chat form(Snap-in) are not attached to Live Chat transcript record - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Ramesh AleRamesh Ale 

Contact and Case records created from Pre-chat form(Snap-in) are not attached to Live Chat transcript record

We are using snap-in feature on Napili template but case and contact records created through pre-chat form are not attached automatically to the Chat transcript record.

Unlike the old Live Agent, Snap-in lets admin customize what information to be collected from the pre-chat form and what records to be created as shown in the below screenshot: 
User-added image

For the customer on Napili template, who wants to chat with agent, shows the below pre-chat form as expected: 

User-added image

So far, so good but the contact and case records created using the information collected from pre-chat form are not attached to the live chat transcript record and agent has to do manually.

There was a similar question (https://salesforce.stackexchange.com/questions/57058/adding-chat-transcript-to-case-in-live-agent) for LiveAgent and the suggested solution was to use pre-chat API but Snap-in doesn't give any option to write any custom code so not sure how to use Pre-chat API with Snap-in.

NOTE: We opened case with Salesforce support but they keep closing saying we can do this using pre-chat API but they don't give details of how to use Pre-chat API with Snap-in for Napili template.

Any help on this?
Jeff MayJeff May
Support is correct. The Snap In lets you collect the info from the customer, but if you want to do custom processing on it (like search/create/attach Contact or Case to the chat), you have to use the Live Agent API.  You can find resources and example code for the Live Agent API on the Developer Community:  https://developer.salesforce.com
Ramesh AleRamesh Ale
Jeff,

I am aware of how to Pre-chat API with LiveAgent. If Pre-chat API can be used with Snap-in, I need pointers on how to do that. 

Just to make sure, I understand, Are you saying that snap-in can create Contact and Case records from the information entered in the Pre-chat form but cannot associate those records to the Live-chat transcript? Please confirm.

I don't think support is saying that we have to switch to Live Agent to acheive this. They are simply saying that we can use pre-chat API to attach contact and case records to Chat transcript records. They did not mention anything about switching to Live Agent.
Marco FantiMarco Fanti
Hi Deter,
at the end, have you managed to use the LiveAgent API with Snap-In, or have you abandoned the snap-in and used only the Live Agent?
We also need to use the Live Agent API with Snapin, if possible, but I don't find any help on this.
Best regards!
Marco
Ramesh AleRamesh Ale
Hi Marco,

For now, we have trained our agents to manually attach the contact and cases created during the chat session to the chat transcript record manually.

I am not sure if we can use Live Agent API with Snap-In to attach the case and contact records automatically to the chat transcript record. If I remember correctly, we should use either Live Agent or Snap-In and I don't think we can mix it.

I am going to look into it again to see if I can inject some Javascript to attach the contact and case records automatically. I will update this post if I have any sucess. Thanks!
Ceejay QuachCeejay Quach
Hi Deter,

I also have the same problem attaching Contacts to a Live Agent Transcript record. Have you found a solution to this?

Thanks,
Ceejay
MOHAMMED BAZEETH NAINAR V MMOHAMMED BAZEETH NAINAR V M
Hi Ceejay,

Are the Contacts and Case records getting created for you ?, For me even Case and contact records set up in pre-chat form are not getting created.

Any help on this ?
Ramesh AleRamesh Ale
@Ceejay,

No, I did not find solution for this. For now, we are asking users to manually attach contacts to transcript.

Thanks
Ceejay QuachCeejay Quach
@Deter,

Thanks for letting me know!

@Mohemmed,

Unfortunately, like Deter, I have not found a solution to get the pre-chat form to automatically create case and contact records.
Mechelle ClarkMechelle Clark
Hi,

@ceejay,

I wanted to let you know that we used code from the Pre-chat Form Code Sample on page 40 of the developers guide and seems to have worked so far.  It does create a case and creates the contact if it doesn't exist. The only issue I'm having is it doesn't associate the Live Chat Transcript to the case or contact either. We are manually attaching for now.

see page 40 of this guide:  https://resources.docs.salesforce.com/214/latest/en-us/sfdc/pdf/live_agent_dev_guide.pdf
Tim RobinsonTim Robinson
In our implementation, we are using the OOTB Community Snap-In component. The Case and Contact are created and attached to the Live Agent Transcript without any additional custom work in a custom prechat form, both of which will be popped for an agent with the chat. When using Person Accounts, if an existing Person Account is found based on matching first name, last name, and email, that record will be attached to the Live Agent Transcript and popped instead of a Contact record. If a Person Account does not match, a Contact record will be created and popped. This Contact creation can be blocked using a validation rule if desired.

Since there is a lot of confusion and lack of documentation on the Snap-In implementation for Community vs a general public-facing website, I would like to include some of the limitations of a Community-based Lightning component prechat form I've discovered so far here.

At this moment, the full Snap-In embedded_svc library structure is not available in Lightning. If you are developing in a Community and using the OOTB Ligthning Snap-In component, for example, you are limited only to the methods referenced in this documentation: https://developer.salesforce.com/docs/component-library/bundle/lightningsnapin:prechatAPI/documentation, which is much more limited than the embedded_svc library.

The limitation of access to the embedded_svc library is indirectly called out here: https://help.salesforce.com/articleView?id=snapins_chat_limitations.htm&type=0%C2%A0
  • "You can’t embed Snap-ins Chat into Lightning components. Use a Visualforce page, Community, or web property only."
A couple of notes there:
  • I'm assuming "web property" there refers to the non-Lightning component implementation that uses the embedded_svc library
  • If in a Community, you can embed the Snap-In library into a VisualForce page, but the button itself hugs the bottom of the VisualForce page, not the actual bottom of the window. I'm not sure if you can have this chat persist from page to page like the web implementation or the OOTB Community implementation
  • Again from above, in the OOTB Community implementation, there is no access to the embedded_svc library, so the ability to exert control over the records getting created and things like direct-to-button routing are not available yet for the Community
In a Community, it is possible to create a rich pre-chat form and build a custom display for the prechat fields, as long as you start a chat by passing the formatted fields that are expected.
Nikhil KasthuriranganNikhil Kasthurirangan
I also came across this problem, but it seems like the Live Agent APIs are not compatible with the new snap-ins. So, I ended up trying a bunch of things and finally the following attached the Contact Record to the Chat:
embedded_svc.settings.extraPrechatFormDetails = [{
                'label':'First Name',
                'name':'FirstName',
                'value':'Jane',
                'displayToAgent':true
            },
            {
                'label':'Last Name',
                'value':'Doe',
                'displayToAgent':true
            },
            {
                'label':'Email',
                'value':'janedoe@goforbroke.gov',
                'displayToAgent':true
            }];

        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',
            'saveToTranscript':'Contact' // This is the important field
        }];

Basically, what the above says is that using the labels in the extraPreChatFormDetails (this is an alternative to a pre-chat form, which I am not using. So, if you are using a pre chat form, then use its labels as needed), attach the Contact Record (if found) to the chat transcript field "Contact" [On the Live Agent Console, this is "Contact Name"].

Note: The above assumes that the Contact Record, matching First Name, Last Name and Email exists in Salesforce. If it does not exist, then just set all doCreate flags to true.

Hope this helps. 
smitha vikramsmitha vikram
i have set up a snap in and live agent that captures new cases coming but in rare occurrence, we might pick an existing case to add a transcript to. Thus, is there a way to auto-create a case opening it in the Lightning Console Chat Transcript window or sub-tab with some pre-populating of fields without including a case field in the pre-chat? Or is the easiest method to include something like "subject"?
monika Shirkemonika Shirke
Hi All ,
i have custom Per chat form (aura component) . Not able to create contact from it 
Also check the standard per chat from , there i have selected Contact , There also no Contact is created for chat session .

@Nikhil Kasthurirangan & All  Where to apply the below code ? 
embedded_svc.settings.extraPrechatFormDetails = [{
                'label':'First Name',
                'name':'FirstName',
                'value':'Jane',
                'displayToAgent':true
            },
            {
                'label':'Last Name',
                'value':'Doe',
                'displayToAgent':true
            },
            {
                'label':'Email',
                'value':'janedoe@goforbroke.gov',
                'displayToAgent':true
            }];

        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',
            'saveToTranscript':'Contact' // This is the important field
        }];
Thanks in advance