Slider 2TryLearn MoreSlash your Phone bills - Slider Image

Use SIP trunks, WebRTC & Apps

Slash your Phone Bill by 80%

Course Content - Advanced

Advanced Inbound Routing


Welcome to the online training series from 3CX. This module will take you through the advanced inbound routing with 3CX.


3CX, in addition to the routing of incoming calls based on the number which was dialled, a DID that is, can also route calls based on the Caller ID of the person calling.

We will also showcase the Caller ID reformatting, which will allow you to change the format of the incoming number, and present it in its modified form on the phones’ screens.


The routing of calls based on the Caller’s ID is done in exactly the same way as DID routing, but will ignore what number has been dialled and focus solely on the origin of the call.

A Caller ID inbound rule will, like a DID inbound rule, be able to route calls differently based on the time of day, with a different routing during office hours and outside of office hours.

Also, a Caller ID inbound rule can also have a holiday routing assigned to it.

Whereas an inbound rule for a particular DID can only be assigned to one SIP trunk, as this DID will be provided by that particular SIP Provider, a Caller ID inbound rule can have the same Caller ID rule assigned to multiple trunks, as someone from a particular Caller ID will be able to call you on any one of your SIP Trunks and consequently, your DIDs.


From the “Inbound Rules” page select the “Add CID Rule” button.

You can optionally give a name to this inbound rule, which will be prepended on incoming calls and show the name of the rule on the phones’ screens. This will help you to identify where the caller is coming from.

You will then need to set the Caller ID mask, which the PBX will use to identify the caller. You can add the number in it’s entirety, identifying a single caller, or use the * as a wildcard. For example 0044* will identify a UK Caller and 004420* will identify a caller from London.

Next, the routing of this call will be selected, to point to the destination.


The ordering of the rules is very important in 3CX. If the rules are ordered incorrectly, the incoming call will be routed to the wrong destination.

The inbound rules are ordered per trunk. The inbound rules for one trunk will not overlap with the inbound rules of another trunk.

The rules are processed, on a per trunk basis, in a top down fashion. When the PBX matches a number to a rule, it will process the call and ignore any subsequent rules.

We can see an example scenario below.

An incoming call is coming from 00442033272020 to 00498922061592

With the first scenario, the call will go to the inbound rule defined as a DID rule for the number *061592, irrespective that the call is coming from a UK number. The match has already been made by the DID Number.

If we want to have calls from the UK to be treated differently, Caller ID inbound rule will need to be brought to the top of the list. In the second scenario the call will follow the routing defined by the Caller ID rule.


The PBX can modify the format of the Caller ID coming in through a SIP Trunk.

This modification is performed based on some 3CX specific Regular Expressions.

The PBX will identify a Source Pattern and then reformat, or replace the number based on a Replace Pattern.

Some providers, in addition to the Caller ID Number, may also send a Caller ID Name. This may be the same as the Caller ID number or may even be text, for example, the company name. The PBX will not reformat this Caller ID name, but will only modify the Caller ID Number.

More information can be found at our Caller ID Reformatting technical document found at the URL which is in the slide.


The Caller ID reformatting is very helpful in some scenarios where a provider may send the Caller ID in an inconvenient format, for example it will be sent as a non dialable number, and the number cannot be used by a user when trying to redial this number.

An example scenario is like the one presented here.

A call comes in from the UK. The provider sends the Caller ID Number as 442033272020. The extension misses the call. When the user attempts to redial this number, the PBX will not be in a position to recognise the number when it is dialled in this format.

Some PBXs may also have different providers which will send the caller ID in different formats, making it difficult for the users to manage dialing numbers.

A provider may send the number in the format shown on screen here, but another provider on the same PBX may show the same number as with a leading + sign.

A solution is to modify the numbers starting with 44, adding a 00 to the beginning of the number and then routing the call through to it’s destination.


The reformatting of the number is done from within the SIP Trunk configuration. In the configuration of the SIP Trunk, go to the “Caller ID” tab.

In the “Inbound” section, click “Add”. The editing box is then shown, which will allow you to configure the formatting.


The source pattern is structured in the following way.

A simple dot will represent a single digit.

Two dots will represent two digits and so on. So, if you want to have an eight digit number represented, you would write this down as eight dots.

A dot followed by a star will represent the rest of the digits. This is used at the end of an expression to specify any numbers following.

You can also identify specific digits, from 0-9. A plus sign in the number can also be represented.

Any characters of the source pattern can be isolated as variables by enclosing them within a set of parentheses.

For example, to identify numbers coming from the UK, the source pattern would start with the known country code, for example, 44 which comes from our scenario mentioned in slide number 7. It would then be followed by any number.

So our source pattern would become 44(.*)

[SLIDE 10]

The Replace Pattern is used to modify the number after it has been identified by the Source Pattern.

The number will be re-written with numbers and/or a plus sign at the beginning of the number.

A backslash will then be used to add a value of a variable defined in the source pattern. Each subsequent variable will be addressed by a number. The first, leftmost variable will be variable number 1, the second variable to the right will be variable number 2, and so on.

Taking our sample number from our scenario, we can apply the source pattern of 44(.*), meaning all numbers starting with 44 and replace it with 44\1. This will in effect give you the same number.

We could also add the number 44 as a variable and add it in parentheses, followed by dot star, also in parentheses.

The replace pattern in this scenario could be +44\2. This will give you the number +44 followed by whatever is in the 2nd variable, in this case the resulting number would be +442033272020

If we add the source pattern (44)20(.*), where we basically add the country code 44 as a variable and the area code 20 as a fixed number followed by the local number as the rest of the numbers, we could replace the number with the pattern +44\2. This would result in the number +4433272020. Please note that this is an invalid number but just used as an example to demonstrate the Replace Patterns.

[SLIDE 11]

Let's have a look at some examples to test your knowledge of what you have learnt in this module.

We want to reformat the number starting with 44 to international format. So from 442033272020 we want to reformat the number to 00442033272020, by adding a 00 at the beginning of the number.

Secondly, we want to convert an international number to local format. So from 00442033272020 to convert to 33272020, how would the re-formatting be done?

Feel free to pause this video and try this exercise, before moving on to the next slide to see the answer.

[SLIDE 12]

Our source pattern for the first example is 44(.*). The .* as it is placed in parentheses will be the first variable. So the Replace Pattern is 0044\1.

The 2nd example will have a source pattern of (0044)(20)(.*). The 0044 will be variable number 1. (20) will be variable number 2. (.*) will be variable number 3. Our replacement pattern will only need to be \3 to only show the local number, without the international dial code, or the London area code.

[SLIDE 13]

Thank you, and goodbye!

Free for up to 1 year! Select preferred deployment:


for Linux on a $200 appliance or as a VM

Get the ISO


for Windows as a VM

Download the setup file

On the cloud

In your Google, Amazon, Azure account

Take the PBX Express