- 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