# DIDs and Extensions: Incoming Call Handling Treatment

Incoming call handling treatment is the administrative function used to instruct CM how to route incoming calls traversing specific trunks.

The trunk-group I’m using in this example is an ISDN PRI, and the incoming call handling treatment feature that we’ll be using is “public-ntwrk” (because our calls are coming from the PSTN). This is the incoming call handling treatment for trunk-group 45:

```
display inc-call-handling-trmt trunk-group 45 Page 1 of 30
INCOMING CALL HANDLING TREATMENT
Service/ Number Number Del Insert Per Call Night
Feature Len Digits CPN/BN Serv
public-ntwrk 10 7408352200 10 7074
public-ntwrk 10 74083526 6
public-ntwrk 10 740835275 8 11
public-ntwrk 10 74083527 6
public-ntwrk 7 8352200 7 7074
```

In NANP, unique telephone numbers are exactly 10-digits in length:

NPA (Numbering Plan Area Code): 3 digits NXX (Central Office / Exchange Code): 3 digits XXXX (Subscriber Number): 4 digits

The quantity of digits, or “number length”, that are used for incoming call handling treatment in the USA are generally 4, 7, or 10 digits, but arrangements may be made with your carrier/telco to send whatever value you want.

When determining how to handle a call, CM uses the most specific applicable rule. That is to say, it ignores all of the rules that are not of the correct number length, and then it orders the rules by longest “number digits” to shortest “number digits”, and uses the first rule that matches. After the rule matches, it deletes the defined quantity of digits, beginning on the left side of the digit string, and then inserts the defined digits on the left side of the digit string.

Referring to the above example treatment, consider what CM will do if we receive digits 7408352752:

- Determine that the number length is 10 (narrowing the possible rules to only those with “number len” 10)
- Check for “number digits” = 7408352752. No rule matches, so it keeps looking for rule matches.
- Check for “number digits” = 740835275. A match is found.
- The effective rule indicates that 8 digits should be deleted. From the left, 8 digits are deleted, so the digit string is mutated from “7408352752” to “52”.
- The effective rule indicates that the digit string 11 should be inserted on the left. The digit string is mutated from “52” to “1152”.
- The dialplan analysis table is consulted to determine whether 1152 is a valid digit string. If 1152 is a valid digit string and is an extension, the call is delivered to that extension. If it is not a valid digit string or there is no matching extension, intercept treatment applies.

Now let’s change the example just a bit, and re-evaluate what would happen if CM received digits 7408352752:

```
display inc-call-handling-trmt trunk-group 45 Page 1 of 30
INCOMING CALL HANDLING TREATMENT
Service/ Number Number Del Insert Per Call Night
Feature Len Digits CPN/BN Serv
public-ntwrk 10 7408352200 10 7074
public-ntwrk 10 74083526 6
public-ntwrk 10 74083527 6
public-ntwrk 7 8352200 7 7074
```

- Determine that the number length is 10 (narrowing the possible rules to only those with “number len” 10)
- Check for “number digits” = 7408352752. No rule matches, so it keeps looking for rule matches.
- Check for “number digits” = 740835275. No rule matches, so it keeps looking for rule matches.
- Check for “number digits” = 74083527. A match is found.
- The effective rule indicates that 6 digits should be deleted. From the left, 6 digits are deleted, so the digit string is mutated from “7408352752” to “2752”.
- The effective rule indicates that no digits should be inserted. The digit string remains “2752”.
- The dialplan analysis table is consulted to determine whether 2752 is a valid digit string. If 2752 is a valid digit string and is an extension, the call is delivered to that extension. If it is not a valid digit string or there is no matching extension, intercept treatment applies.

By now, you’re hopefully able to realize that in the example, if we receive either digits “7408352200” (10 digits) or “8352200” (7 digits), the call will be delivered to extension 7074 (because we’re deleting all of the received digits, and then inserting digits 7074).

I mentioned above that if the final digit string is invalid or otherwise not a valid extension, intercept treatment applies. You can determine how intercept treatment is applied by reviewing your system-parameters:

```
display system-parameters features Page 1 of 20
FEATURE-RELATED SYSTEM PARAMETERS
[...]
DID/Tie/ISDN/SIP Intercept Treatment: announcement 3447
[...]
```

In my case, announcement 3447 is played to the calling party, and then the call is terminated. That announcement’s message is to the effect of:

“You have reached [organization name]. The number you have dialed is currently out of service. Please hang up, and try your call again. If you feel you have reached this recording in error, please instead call [number to call for assistance].”

You’re also able to set intercept treatment such that the caller is transferred to an attendant (if you have any attendants configured), or to a VDN. I recommend sticking to an announcement, as 1) your callers should theoretically never encounter this situation, and 2) playing an announcement and then disconnecting is the same behavior as is generally exhibited by the PSTN.