Objective
To retrieve data from Salesforce APIs, a phone number or Automatic Number Identification (ANI) must be provided. To ensure consistency in format, the phone number is standardized using a Set Variable Panel with a Regex Replace function. This process extracts only the 10-digit phone number, removing any prefixes such as "+", "1", or "+1".
Additionally, an optional Set Variable Panel can be used to clean and separate the Caller ID Name (CNAM) into distinct first name and last name variables. This can be particularly useful in workflows that involve creating contacts and assigning values to their respective name fields.
Below are two templates: one for ANI and another for CNAM, designed to extract and format these values from Sharpen before passing them into Salesforce.
Salesforce Get ANI Logic+ JSON Template
{
"panels":[
{
"type": "setVariable",
"initiator": true,
"name": "getCIDAndFormatRegex",
"coordinates": {
"x": 514,
"y": 201
},
"fields": {
"variables": [
{
"name": "cidNumber",
"value": {
"operation": "RRPL",
"values": [
"$(ani)",
"(?:\\+1|1)?(\\d{10})$",
"$1"
]
}
}
]
},
"exits": {
"default": ""
},
"version": "2.0.0",
"description": "Formatting the callerID, removing the 1, +, or +1 so that the callerID is ten digits."
}
]
}Salesforce Get CNAM Logic+ JSON Template (Optional)
{
"panels":[
{
"type": "setVariable",
"initiator": true,
"name": "setFirstNameAndLastName",
"coordinates": {
"x": 80.76480162125046,
"y": -225.34112270023795
},
"fields": {
"variables": [
{
"name": "firstName",
"value": {
"operation": "RRPL",
"values": [
"$(cnam)",
"^\\s*([A-Za-z]+).*",
"$1"
]
}
},
{
"name": "lastName",
"value": {
"operation": "RRPL",
"values": [
"$(cnam)",
"^.*\\b([A-Za-z]+)\\s*$",
"$1"
]
}
}
]
},
"exits": {
"default": ""
},
"version": "2.0.0",
"description": "Returning CNAM, separating first name and last name, finally writing the first name and last name fields."
}
]
}