Using Asterisk and FreePBX how can I map extensions to outbound routes

asteriskfreepbxtrixboxvoip

I have a Trixbox server (Asterisk and FreePBX) that has multiple tenants on it. I need these tenants calls to go out via different outbound routes in order to split the bills at the SIP trunk provider end. Essentially the extensions need to be grouped and each group needs to have it's own outbound SIP trunk.

This used to be achievable using custom contexts in FreePBX but that functionality no longer exists. How can this be done now? I'd be happy to change to a different VoIP distribution which provides this functionality however I need it to be Asterisk and FreePBX based as that's what the customer knows.

Best Answer

We usually do this by adding contexts in the extensions_custom.conf file. These custom contexts include the default contexts but listen for your outbound calls such as NXXNXXXXXX, 1NXXNXXXXXX and add your dialing codes such as 7777 to the beginning of the call. Then you simply setup your outbound routes so the specific routes are listening for the relevant codes and stripping them off before pushing the call to the carrier.

Phones belonging to client1 would be set in "custom-client1" context while client2 phones would be in "custom-client2".

[custom-client1]
exten => _NXXNXXXXXX,1,Dial(Local/888${EXTEN}@from-internal)
exten => _1NXXNXXXXXX,1,Dial(Local/888${EXTEN}@from-internal)
exten => _NXXXXXX,1,Dial(Local/888${EXTEN}@from-internal)
include => from-internal

[custom-client2] 
exten => _NXXNXXXXXX,1,Dial(Local/889${EXTEN}@from-internal)
exten => _1NXXNXXXXXX,1,Dial(Local/889${EXTEN}@from-internal)
exten => _NXXXXXX,1,Dial(Local/889${EXTEN}@from-internal)
include => from-internal
Related Topic