Add dialing rules for Tenfold
Overview: Organizations often need to manipulate phone numbers to use them with Tenfold. Some locations need to include a leading digit to initiate an outbound call, while others may need to make more complex changes, such as substituting local codes for country codes to make local calls. Additionally, phone numbers stored in a CRM are frequently not in the correct format to use for dialing. Dialing rules make it possible to transform phone numbers seamlessly, reliably, and consistently between the backend and the end user.
Understand regex basics
NOTE: A good resource for checking your regular expressions is https://regex101.com.
Regex is short for "regular expression" and is a way to match character patterns in text. Because dialing rules are implemented using regex, it is important to first understand how regex works before attempting to build your own rules.
Regex can be used to:
- find patterns
- replace patterns in text with different characters
- validate input
- manipulate input
The following table is a basic reference for regex metacharacters (groups of characters with special meaning) frequently used in dialing rules. For a comprehensive regex reference, see https://www.regular-expressions.info/reference.html.
Metacharacter | Description |
. | Match any single character. |
[a] | Match the characters inside the square brackets (in this example, match only "a"). Can also include sequential character ranges like [a-z] or [1-5]. |
[^a] | Match any character that is not inside the square brackets (in this example, match anything except "a"). |
* | Match the preceding character 0 or more times. Example: |
+ | Match the preceding character 1 or more times. Example: |
{a,b} | Match the preceding symbol at least "a" times but not more than "b" times. Example: p{3,5} means to match the letter "p" at least three times but not more than five times. |
(abc) | Exactly match the group of characters inside the parentheses (in this example, "abc"). |
| | Match the characters either before or after the symbol. |
\ | The escape symbol. This symbol lets you match "reserved" characters (those that would otherwise be interpreted as part of a regular expression) as literal characters in text. Example: Match the plus sign character: \+ |
\d | Match any decimal digit (0 through 9). |
\s | Match any whitespace character. |
? | Match 0 or 1 occurrence of the preceding regular expression. |
^ | Indicates the start of the input. |
$ | Indicates the end of the input. |
$n | Using $<n> (example: $1) indicates a numbered group which can be used as the target of a substitution. |
Using dialing rules with Tenfold
You can use dialing rules to:
- Perform search-and-replace operations on phone numbers passed from the backend to CCS for outbound calls using Click to Dial or the dial pad in the Tenfold app.
- To transform phone numbers stored in the CRM into a format that the PBX expects, or vice versa. Some examples of common modifications to backend numbers include:
- Putting numbers in E.164 format
- Adding the exchange + to the international dialing prefix for a country
- Adding the exchange for a local country code
- Applying rules for calling different regions in the same country
- Applying rules for calling mobile lines
- Perform search-and-replace operations on phone numbers passed from the PBX to CCS in call events. Example: Send different phone numbers for inbound and outbound calls.
- Use with TCC to distinguish internal numbers to apply dialing restrictions.
Adding common dialing rules
CCS and TCC support dialing rules. The method and format of adding the rules is different for each.
Cloud Connect Server (CCS) dialing rules examples
Add dialing rules through the CCS UI by clicking Rule and changing the type to Dialing. Include regular expressions in the Match and Replace fields.
Table 1. Examples of dialing rules in CCS
To perform this task | Use this rule | Notes |
Match only this exact phone number 1555799232. | In the Match field: ^1555799232$ | Match: 1555799232 |
Match either of these phone numbers: 1555799232 or 1555799233. | In the Match field: ^1555799232$|^1555799233$ | Match: 1555799232 |
Match three numbers which differ only by the last digit: 1555799230, 1555799231, 1555799232 | In the Match field: ^155579923[0-2]$ | Match: 1555799230 Match: 1555799231 Not a match: 1555799235 |
Match all phone numbers starting with 155 | In the Match field: ^155\d* | The rule matches all character groups that start with 155, regardless of length and whether they include letters or special characters. |
Match phone numbers starting with 1, 2 or 3. | In the Match field: ^[123] | Match: 1555799232 For the given rule, matches include any strings starting with 1, 2, or three, including 1555799232. |
Match only phone numbers which include digits. | In the Match field: ^\d*$ | Match: 1555799232 Not a match: +1555799232 |
Match phone numbers starting with 15, 25, or 35. | In the Match field: ^[123][5] | Match: 1555799232 |
Match phone numbers starting with 15, 25 or 35. | In the Match field: ^(1|2|3)(5) | Match: 1555799232 Match: 2555799232 Match: 3555799232 Not a match: 4555799232 |
Match phone numbers starting with 770 and add 9 to the number. | In the Match field: In the Replace field: | Match: 7705555555 Result: 97705555555 |
Match phone numbers starting with + and not followed by 57; substitute 0005 for the plus sign. | In the Match field: In the Replace field: | Match: +5865555555 Result: 00055865555555 The number matches the pattern. The plus sign (+) is replaced by 0005. The final formatted number is 00055865555555. Remember to use the escape character backslash (\) to escape the plus sign (+) so it is used in pattern matching and not evaluated as part of the expression. |
Match phone numbers not starting with 57 and add a plus sign (+) to the start of the phone number. | In the Match field: In the Replace field: | Match: 5865555555 Result: +5865555555 The Match field matches 5865555555, and the Replace field adds a plus sign (+) to the first position. |
Match phone numbers starting with +571 and replace +571 with 0. | In the Match field: In the Replace field: | Match: +57165555555 Result: 065555555 The Match field matches +57165555555, and the Replace field substitutes 0 for +571. |
Match phone numbers starting with +57 but not +571 and not +573. Replace +57 with 005. | In the Match field: In the Replace field: | Match: +5742515433 Result: 00542515433 The Match field matches +5742515433 and the Replace field substitutes 005 for +57. |
Tenfold Cloud Connect (TCC) dialing rules examples
Dialing rules for TCC are added to the config.properties
file using phonesystem.command.dial.rule.
<number>
settings. Rules are usually created in pairs, called rule sets, consisting of a match rule and a replace rule. The match and replace rules in the set must always have the same number. Match rules without a corresponding replace rule cause all matching items to be removed. Be sure to use a unique number for each rule set (do not reuse rule set numbers in the same configuration).
Always ensure that there is a phonesystem.command.dial.rule.count=
<x>
line in the config.properties
file. This line must be included prior to the list of match and replace rules. The <x> in this setting is the total number of rule sets (one match rule and its corresponding replace rule counts as one rule).
Table 2. Examples of dialing rules in TCC
To perform this task | Use this rule set | Notes |
Prefix 9 to all phone numbers with 6 or more characters, except those starting with 1101. |
| Match: 4405555555 Result: 94405555555 No match: 11019105555555 |
Match a 9-digit number that doesn’t begin with 9 and add a 9 to the beginning. |
| Match: 7705555555 Result: 97705555555 No match: 9105555555 |
Match a phone number that is 10 digits or more and add a 1 at the beginning. |
| Match: 447911123456 Result: 1447911123456 |
Match a phone number that begins with 1 and is followed by 10 more digits. Remove the leading 1. |
| Match: 123911123456 Result: 23911123456 No match: 447911123456 |
Match a phone number that begins with a + and remove it. |
| Match: +123911123456 Result: 123911123456 Because there is no definition for the Replace rule, the plus sign (+) is removed by the Match rule |
Match a phone number that contains a dash (-) and remove it. |
| Match: 910-550-5555 Result: 9105505555 NOTE: There are multiple types of dashes that look the same, but have different character codes which can affect pattern matching accuracy and consistency. |
Match a phone number that contains a left parenthesis ( and remove it. |
| Match: (9105505555 Result: 9105505555 |
Match a phone number that contains a right parenthesis ) and remove it. |
| Match: 910)5505555 Result: 9105505555 |
Match a phone number that contains an en dash (–) and remove it. |
| Match: 910–550–5555 Result: 9105505555 This is an example of another type of dash. Because it is a different character than the first dash example, this number is not a match for this regular expression: No match: 910-550-5555 |
Match a phone number that contains an em dash (—) and remove it. |
| Match: 910—550—5555 Result: 9105505555 An example of yet another type of dash. |
Match and remove left parentheses, right parentheses, and three types of dashes. Remove the matching characters. |
| Match: (910)123-4567 Result: 9101234567 |
Missing Something?
Check out our Developer Center for more in-depth documentation. Please share your documentation feedback with us using the feedback button. We'd be happy to hear from you.