Using different Trunk for outbound calls based on extension

Is there a semi-easy way to set the system up to allow defining specific extensions or groups of extensions to use a different trunk or outbound route?

Basically… we are looking to have more then 1 company using our PBX. Inbound routes are easilly handled by DID.

Thanks!

See http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/customcontexts

I had looked at Customcontexts, however was told that it didn’t work with the latest versions of Freepbx, etc. Is this not the case?

And it still seems to be working as before. We ran into a different problem after the upgrade, but I don’t think it has anything to do with Custom Contexts.

Odd… I installed it on 2.2.3 (under Trixbox 2.2.4) and although the install worked, and the setting options are there, the system doesn’t follow the rules at all. It’s like they aren’t even there.

Any ideas?

I discovered that also. You have to disallow the outbound-allroutes and from-internal contexts from within your custom context screen and individually assign each context you wish to use. It works on mine that way.

What about FreePBX 2.3. Is somehow possible to make compatible CustomContexts with FreePBX 2.3.x?

Are you referring to within the Custom Contexts settings? I did have “All outbound routes” set to Deny. I don’t see a setting in this area to deny “from-internal”.

I’ve recently installed Custom Contexts with the latest 2.3 version of FreePBX and it seems to work fine, once you get the settings right as mentioned above.

What are the specific changes you made to get it working?

ALLOW set on everything except:

ENTIRE Basic Internal Dialplan
ALL OUTBOUND ROUTES

Then set Allow or Deny as appropriate for each outbound route.

If you use ZAP hints, you need to add the appropriate ones in the -custom section of each outbound route block (from within extensions_custom.conf) like

[outrt-001-BT1-Main-custom]
exten => 151,hint,ZAP/1
exten => 152,hint,ZAP/2
exten => 153,hint,ZAP/3
exten => 154,hint,ZAP/4

[outrt-004-BT2-Main-custom]
exten => 155,hint,ZAP/5
exten => 156,hint,ZAP/6

Well… here’s what I have…

I click on the custom context to edit. I choose “Set all to:” and set to “Allow”

I then go to “Entire basic internal dialplan” and set to "deny"
Then go to “All outbound routes” and set to "deny"
Then go to “Outbound Routes” and “allow” only the outbound I want and “deny” the other.

I have 2 trunks defined, one for each DID.
I have 2 outbound routes defined, assigned to each trunk.

I then have extension 200 set to custom context “Outbound1”, and
extension 201 set to custom context “Outbound2”.

If I make an outbound call from 201, it does seem to grab the 2nd trunk (per callerid).
However, when I try an outbound call from 200, I immediately get “All circuit are busy now…”

The only way I seem to be able to fix that, is to add the 2nd trunk to the Trunk Sequence in the Outbound1 route. Then the call is actually placed, but comes across using the 2nd trunk, which is actually 2nd in that trunk sequence.

No one?

Can you try swapping trunk1 & trunk2 between the two routes?

If the problem changes to the other phone, the problem is in the trunk somehow. (I’d guess it is, from what you say above).

Do you have exactly the same dialplan info etc. in both trunks?

Good call… I swapped them, and now the phones using the now switched to Trunk2 work, but not the Trunk1 phones.

Odd thing is… if I remove Trunk2, or add Trunk2 to the outbound route that contains Trunk1, the calls work… but go out over Trunk2.

Wonder how to proceed.

The instalation and configuration of custom contexts passed good, but then i try to apply cinfiguration changes (apear on the bottom of page), its give me an error:

Warning: array_keys(): The first argument should be an array in /var/www/html/admin/extensions.class.php on line 189

Warning: Invalid argument supplied for foreach() in /var/www/html/admin/extensions.class.php on line 189
Please update your modules and reload Asterisk by browsing to your server.

1 error(s) occured, you should view the notification log on the dashboard or main screen to check for more details.

and don’t apply the changes. The only thing can i do is to push the “Retry” button.