1
  • I have setup Embedded Chats for Sales flow
  • So new chats will be linked to Leads
  • I am using Embedded Service API for overriding this behavior to implement my usecase
  • My use case -
    • When a new request is coming first lookup to existing Contacts if found then link it with chat
    • If existing Contacts not found then lookup to existing Leads
    • If no existing records are found then create new Lead
  • SF implements this usecase by default when Contacts are created by converting Leads
  • My client org is having Contacts which are not converted from Leads
  • So following script I am using to achieve my use case -
         embedded_svc.settings.extraPrechatInfo = [
                
                {
                    "entityName": "Contact" ,
                    "saveToTranscript " : "ContactId",
                    "entityFieldMaps": [
                        {"isExactMatch": true , "fieldName": "FirstName" , "doCreate": false , "doFind": true , "label": "First Name"} ,
                        {"isExactMatch": true , "fieldName": "Email" , "doCreate": false , "doFind": true , "label": "Email"} ,
                        {"isExactMatch": true , "fieldName": "LastName" , "doCreate": false , "doFind": true , "label": "Last Name"}
                    ]
                } , 
                
                {
                    "entityName": "Lead" ,
                    "saveToTranscript " : "LeadId",
                    "entityFieldMaps": [
                        {"isExactMatch": true , "fieldName": "FirstName" , "doCreate": true , "doFind": true , "label": "First Name"} ,
                        {"isExactMatch": true , "fieldName": "Email" , "doCreate": true , "doFind": true , "label": "Email"} ,
                        {"isExactMatch": true , "fieldName": "LastName" , "doCreate": true , "doFind": true , "label": "Last Name"}
                    ]
                }
                
                
            ];

  • This script work fine for Existing Leads and new Leads, but when existing Contacts are coming from Chats then it creates a new Lead (a extra record)

I am not sure this approach will implement my requirement, open for any suggestion / help Thanks in advance

1 Answer 1

0

I came across the exact situation in my own org. By default, it appears that the lead record will be searched for or created in the Sales Embedded chat flow. To stop the duplicate creation, I used matching and duplicate rules to prevent the lead from creating. For my situation, I am only matching on email address since it is unique, however, you can make your matching rules as complicated as needed. In my duplicate rule, I also added a condition so this rule only applies to the Automated Process user that will create the lead from chat. If the rule will apply to the entire org, then you will not need to add the condition. enter image description here

enter image description here

Lastly, you will not need the additional lead items in your extraPrechatInfo code since the find and create actions on Lead are native the Sales embedded flow.

I hope that helps.

All the best, Ben

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .