This guide will walk you through the steps of altering the Contact Lookup policy to query for a Contact Record and assign it to the Digital Conversation.
Step 1: Navigating to the Contact Lookup Policy
Start by navigating to the Routing Policies tab and opening the Default Contact Lookup (Digital) Routing Policy.
This policy may already have some configuration in place but for the purpose of this guide we will assume this is an empty fresh policy.
The Contact Lookup can have different logic based on the digital channel the message originated on, for this guide we will focus on SMS but you can also connect WhatsApp to do the same route.
Step 2: Querying the Contact in Salesforce
Firstly start by connecting the SMS Lookup app to an Action container, you can do this by pressing the plus icon next to the SMS lookup app and selecting Action.
Within this container we want to start by adding in a Query app that will allow us to query data from Salesforce.
On the Query Object app we want to configure the following:
Set the Result Set to “Contact”
Change the Record Type to “Contact” so we are querying the Contact object
Click Add fields and set the field to “Mobile Phone” (You can use another phone field if that is what you are using for Contact records)
Under the newly created query parameter created above set the value to $(DigitalChannelAddress) - this will be the phone number of the customer that the message is received from
In the Available fields section we want to return the Contact Id and the Full Name fields
What the above does is it will query Salesforce for any Contact records relating to the phone number that the first message in the conversation was received from, you can change this query to be more specific to your data such as specific Record types should you want to.
Now that we have configured our Contact query we can create a connecting Action container if a result is returned for the contact query. To do this you need to click on the red plus next to the app (it will be the red plus closest to the top right corner of the container) and then press “Action” in the sidebar to create a new action container.
Step 3: Assigning the Contact Record to the conversation
Now that we have created the Salesforce query we need to take the results of this query to assign the returned record to the conversation. In the container that was created at the end of the previous step we need to add an Assign Records app to the container.
In the Assign Records app we need to define the record id as well as the name of record, the name would typically be a first name or full name - in this case we are returning the full name of the Contact record.
Under the Record Id field we want to store the Contact Id field returned in the previous step. The macro we will use is $(SForce_Contact.Id) if you are using a different result set name than the one set in Step 2 you will need to add the macro manually yourself.
under the Display Name fields we want to store the Full name field returned, the macro we will use for this is $(SForce_Contact.Name) the same applies if you are using a different result set as above.
Finally you can save the routing policy by pressing the Save button in the top right corner (you may need to click on the canvas to hide the sidebar).