Once you’ve created your CRM Query Group, you can start adding individual Queries to your group. Multiple data queries can be added to a CRM Query Group to be searched within a Call Flow. Queries in the CRM Query Group will run in the specified order until a record is found. Once a record that matches the query criteria, the data from that query will be returned to the Call Flow.
To create a Query, click Add Query. This will open the Create Query Modal.
- Query Name - The Query Name is used to identify the name of your query in the Query Group. In this example, we’ll be searching for Leads so we’ll enter Lead as our Query Name.
- Object Type - Select the Salesforce Object Type you want to search for. Again, since we’re searching for Leads, we’ll select Lead as our Object Type.
- Filter by - Select an option to Filter by. If we find multiple matches, we can prioritize records by Last Created or Last Updated.
Fields to Match
Fields to Match are the fields we’ll search for on the Salesforce record. For example, we want to search by phone number for this CRM Query Group, so we’ll select the phone number fields on the Lead object that we want to search against. Click on the Field Name dropdown to select a Field to search against.
To add another Field Name, click on Add Field Name.
In this example, we’ll attempt to match our phone number against Phone and Mobile Phone fields on the Lead record.
When done, click Next.
Fields to Return
Fields to Return is the data returned to the Call Flow that will be used in routing decisions on other Call Flow Steps. Select Fields to Return on the Variables that were created in the CRM Query Group.
In this screen, you’ll see the Variables that were previously defined on the CRM Query Group. Name and ID are required so that we present the correct ID and the correct Name when presenting the inbound call to the agent.
Here we’ll use the Full Name on the Lead that we match for the Name Variable. This allows us to use the Full Name field in the Call Flow.
On the Summary page, the information for the CRM Query is shown to review. If everything looks good, click Save to save the CRM Query to the CRM Query Group.
Using Multiple CRM Queries
Continue adding additional CRM Queries by following the steps above. Once you have multiple CRM Queries, you can rearrange the order of your queries to prioritize the query search order.
In this example, the Lead Query has a weight of 1 and the Contact Query a weight of 2. This will search for records using the Lead Query first. If no records are found, we’ll then search using the Contact Query.
The query priority can be changed by dragging the order of the CRM Query. Click on the dots next to the CRM Query and rearrange to the required order.
Now the Contact Query will run first, then the Lead Query.
Once you are done adding your Queries to the CRM Query Group, click Save. Now you can use this CRM Query Group in a Call Flow by choosing it when creating a CRM Query Step.