If you want to count how many calls per lead, opportunity, contact, account, etc… this guide will help you achieve that. Common use cases include:
How many calls for a case to be resolved
How many calls for an opportunity to close-win
How many calls per contact (cost to serve)
This can be done for inbound, outbound or both, you will need to add to do the respective steps.
New Fields
You will need to make some new fields on the desired object you want the counter to apply on. You could have two fields:
Inbound Dial Counter
Outbound Dial Counter
or just one field called ‘Dial Counter’ or something similarly named.
Inbound Calls
Do these steps to implement the counter for inbound calls.
New Data Analytics Policy (Inbound)
Add a new policy, choose the type ‘Data Analytics’ and name it ‘Counter-Inbound’.
From the ‘From Policy’ container, add a new action container and choose a query object app.
If you make US calls, you will need to add the usual number formatting for US numbers to ensure the records can be queried correctly.
Configure that query object app to find the record you are looking for, for example: contact
Make sure to return the ‘Inbound Dial Counter’ field or ‘Counter’ field.
If you have already queried the record in the inbound policy, you can use the macro for that record instead of adding a new query object app.
From where the app returns the record successfully, add a new action container with a Script Engine app.
Add in the script like this:
local currentCounter = tonumber(session.expand_macro('$(SForce_Contact.Inbound_Dial_Counter__c[1])')) or 0 print("Current Counter: " .. currentCounter) -- Value to increase by local increaseCounter = 1 -- Use a number instead of a string print("Increase Counter by : " .. increaseCounter) -- Calculate new Slots Booked value local newCounter = currentCounter + increaseCounter print("New Counter Value: " .. newCounter) -- Set the new value as a string $(Custom_NewCounterValue) session.set("NewCounterValue", tostring(newCounter)) return true
You need to replace the $(SForce_Contact.Inbound_Dial_Counter__c[1]) with the macro for the record you found.
After the script engine, add a new action container with an Update a Record app.
Record Type = Contact
Record ID: $(SForce_Contact.Id)
Set Field Values:
Inbound Dial Counter: $(Custom_NewCounterValue)
Example
Here’s an example for a US based team that wanted to count the number of calls for contacts, accounts or leads.
Existing Inbound Policy Changes
This will need to be added to any existing inbound policies that you want the counter to apply for.
Add a ‘To Policy’ near the beginning of the policy to ensure all calls are captured.
You can choose to put it in a different place but any calls that need the counter will need to pass through the ‘To Policy’. The data analytics policy will only fire after the call but only for calls that pass through the container.
Example
In this example, the call is added after the business hours but before the record app:
Outbound Calls
Do these steps to implement the counter for outbound calls.
New Data Analytics Policy (Outbound)
Add a new policy, choose the type ‘Data Analytics’ and name it ‘Counter-Outbound’.
From the ‘From Policy’ container, add a new action container and choose a query object app.
If you make US calls, you will need to add the usual number formatting for US numbers to ensure the records can be queried correctly.
Configure that query object app to find the record you are looking for, for example: contact
Make sure to return the ‘Outbound Dial Counter’ field or ‘Counter’ field.
If you have already queried the record in the inbound policy, you can use the macro for that record instead of adding a new query object app.
From where the app returns the record successfully, add a new action container with a Script Engine app.
Add in the script like this:
local currentCounter = tonumber(session.expand_macro('$(SForce_Contact.Outbound_Dial_Counter__c[1])')) or 0 print("Current Counter: " .. currentCounter) -- Value to increase by local increaseCounter = 1 -- Use a number instead of a string print("Increase Counter by : " .. increaseCounter) -- Calculate new Slots Booked value local newCounter = currentCounter + increaseCounter print("New Counter Value: " .. newCounter) -- Set the new value as a string $(Custom_NewCounterValue) session.set("NewCounterValue", tostring(newCounter)) return true
You need to replace the $(SForce_Contact.Outbound_Dial_Counter__c[1]) with the macro for the record you found.
After the script engine, add a new action container with an Update a Record app.
Record Type = Contact
Record ID: $(SForce_Contact.Id)
Set Field Values:
Outbound Dial Counter: $(Custom_NewCounterValue)
Outbound Calls (Global) Policy Changes
This will affect all outbound calls in your org unless you specify this is for a certain group of users or type of record.
Similarly to the inbound, it is best to add it near the beginning of the policy to capture all the calls.
You can choose to put it in a different place but any calls that need the counter will need to pass through the ‘To Policy’. The data analytics policy will only fire after the call but only for calls that pass through the container.
Again, this will apply to ALL OUTBOUND CALLS, unless configured for a specific group.
Example
In this example, the call is added after the record app and a script to enable outbound CLI reporting but before the ‘Requested Number’ (Connect a Call app) which is connecting the call.