How to find Contact based on Phone Number instead of Email in Salesforce Embedded Service Deployment?

Use the following code in the Code Snippet. doFind and isExactMatch are set to false for Email, First Name and Last Name. But, doCreate is set to true for Email, First Name and Last Name because when the contact record is created, it will have the values passed from these fields. When the Chat is initiated, the contact is searched based on Phone number. If a matching Contact record is found, it will link it to the matched Contact record. Else, it will create a new Contact with the Last Name, First Name, Email and Phone Number entered.

Phone Field in Pre-Chat:

Sample Code:

embedded_svc.settings.extraPrechatInfo = [ {
"entityFieldMaps": [ {
"doCreate": true,
"doFind": true,
"fieldName": "Phone",
"isExactMatch": false,
"label": "Phone"
}, {
"isExactMatch":false,
"fieldName":"FirstName",
"doCreate":true,
"doFind":false,
"label":"First Name"
}, {
"isExactMatch":false,
"fieldName":"LastName",
"doCreate":true,
"doFind":false,
"label":"Last Name"
}, {
"doCreate": true,
"doFind": false,
"fieldName": "Email",
"isExactMatch": false,
"label": "Email"
} ],
"entityName": "Contact"
}];

--

--

Technical Blogger, Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store