Bind Extension to Outbound Trunk

paior's picture

I really really want to be able to specify that when extension xxx dials outbound it uses X trunk.

I have two people renting offices / phones from me and I want to make it so they don't have to dial a prefix. (they keep forgetting.)

I am willing to pay for support / donate to the project to get this resolved.


__________________


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

custom context

bubba's picture

are you runnnig the 2.2 branch??

http//www.freepbx.org/trac/ticket/1447

in case you do not know how to do a manul install
cd /usr/src
wget http//www.pbx4pros.com/files/freepbx/modules/customcontexts.tgz
cd /var/www/html/admin/modules/
tar -zxvf /usr/src/customcontexts.tgz


__________________

Bubba


MY GOD YOU GUYS ROCK

paior's picture

All is working fantastically!

One minor bug... had to manually specify the context within the extension's context feild, (the drop down list would keep resetting itself to "blank"

So, who gets my gratitude, $50 AUD?


Bind Extension to Outbound Trunk

p_lindheimer's picture

paior,

there is a donate button on the left side of the main freepbx site. That is the best place to send such offers of gratitude, they will directly benefit the project.


__________________

Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here


Bind Extension to Outbound Trunk

idkpmiller's picture

This looks amazing, should have this in the base setup as its really useful.

I am seeing an error at the top of the custom page whenever I select.

Warning: Invalid argument supplied for foreach() in /var/www/html/admin/modules/customcontexts/functions.inc.php on line 589

anyone else seen this and no a fix?

Cheers


Bind User to Outbound Trunk

x75's picture

Hi there,

I run FreePBX with Devices and Users. This module allows me to choose a custom context for the devices but not for Users. Does anyone know if there is a way to do the same for Users. The reason:

We have a bunch of phones that are used by different people. I want them to automaticly dail out a certain trunk depending on what user is using the phone.

Any Ideas?

Btw: I have FreePBX 2.3.0.2 and I'm seeing the same Warning. But all seems to work.

Thanks
x75


custom module

bubba's picture

I do not know about users vs devices
but the error I think comes from not creating a time condition under the custom context module first.

Bubba


__________________

Bubba


Outbound Groups module

rjenkinsgb's picture

Hi,
there is an add-on module (developed by one of the other guys on this forum) which allows outbound groups to be created.

Info & download link in the original thread, here:
http://www.freepbx.org/forum/freepbx/users/new-module-outbound-extension-groups


Hi, thanks for the tip. The

x75's picture

Hi,

thanks for the tip. The module doesn't seem to work for me, after installing it hangs freepbx, till i reboot. And then i have php errors when I open it. I'll try to look into more this weekend, and will post my problems in the thread for the module.

Thank you again,
x75


Outgroups Module

robert's picture

Is it the Outgroups module that you are talking about causing FreePBX to hang? If so, I haven't heard of that problem before. Which versions of FreePBX and Asterisk are you using?

As far as the other problems with PHP errors, they are fixed in the latest version (0.1.6). I borrowed the code for the Extensions page from the Custom Contexts module and it has a few "issues". I rewrote that code from scratch and all the problems should be resolved in the new version.

If you still see any issues after upgrading, please let me know.


I'm having the same issue

jdaustin's picture

I'm having the same issue with the devices being reset to blank after update.
How do you get around that?
I'm trying to bind users/devices 1xx to zap/g0 and 2xx to zap/g1


Custom contexts worked for

jdaustin's picture

Custom contexts worked for me.
The pulldown resets to blank but the actual context field changes and works when you save.
I was able to use custom-contexts to restrict extensions to specific trunks and it's been going for a few days without issue.

JD


I've just tried installing

rjenkinsgb's picture

I've just tried installing 'Custom Contexts' to fix certain extensions to specific trunks.

It does this, but when set to the 'new' context the extensions lose access to hints, or at least the Polycom phones are unable to obtain the status of other extensions.
(The extensions are all available locally, only certain trunks are restricted).

As far as I can see, the only restrictions I have set in the new context are those relating to outbound routes, almost everything is set to 'allow'.

Setting the extension context back to default immediately allows the hints / line status lamps to work again as before.

Does anyone have any info on getting both hints/lamps and custom contexts working together?


Hints fixed...

rjenkinsgb's picture

Well, all internal extension hints started working OK on their own(?)...

For trunk (ZAP) hints, it is neccessary to have a section in extensions_custom.conf for each outbound route block, containing the relevent hint lines.

I originally added the ZAP hints in outbound-allroutes-custom.
This is apparently not used when custom contexts is used - the hints must go in each individual outrt-(name)-custom block, like

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

The hints are then available to phones that include that route in their context.


Trixbox

sirm766's picture

Hi, i also want to bind trunk with extension, Example

extension 1 should make outbound calls from 1 Trunk
extension 2 should make outbound calls from 2 Trunk

I have trixbox latest version installed (Trixbox 2.6.0.7 )

Regards


You probably should post on a TB forum

wiseoldowl's picture

sirm766: Trixbox has taken it upon themselves to fork FreePBX (see "News Announcements" in upper right hand column on this page), and while the changes at this point may be relatively minor, we have no way of knowing whether advice we give you here will work with the latest versions of Trixbox. They have decided that they want to take over coding and support, so I would respectfully suggest that you either ask your questions in one of their forums, or if you want to run "true" FreePBX then use a distribution that includes it, such as PBX in a Flash or Elastix. Note that I am NOT a FreePBX developer, so this should not be taken as an "official" position of the FreePBX team, just as a bit of friendly advice.


To FIX Warning: Invalid argument supplied for foreach() in /var/

fblanchet's picture

To FIX this error after installing Custom Context, (Warning: Invalid argument supplied for foreach() in /var/www/html/admin/modules/customcontexts/functions.inc.php on line 589) just create a "custom context times", no more errors after that.
Thank you!


That error was addressed in

fskrotzki's picture

That error was addressed in 0.3.3 or 0.3.4. which is available here in the FreePBX site. Please take a look at using the latest module code for better results.


Does this work in FreePBX 2.5.1.0

brk's picture

Is there a working solution that goes with 2.5.1.0? I didn't want to go installing modules if there is a major difference in the internals. Or is this funcionality somehow built in now? I looked but couldn't find it.


yes it works

fskrotzki's picture

yes it works


Doesn't work for me

primesoftnz's picture

Running the beta of asterisknow 1.5 with all bundled modules updated for freePBX 2.5.1
3 x pstn trunks g0-g2
2 x SIP trunks
2 x pstn extensions
2 x Hard IP extensions
6 x Soft IP extensions
Tenants have 1 of the pstn extensions Dahdi/5 (6007)
My Home Business has the other Dahdi/4
pstn trunk 1 has dialling prefix 9
pstn trunk 2 has dialling prefix 8
pstn trunk 3 has dialling prefix 7
Sip trunk 1 has dialling prefix 6
Sip trunk 2 has dialling prefix 5
I have been trying to force extension 6007 for the tenants through pstn trunk 3 and restrict them to free calling area only (no number beginning with a "0")
Loaded latest version of custom contexts and setup a custom context "from-tenants".
I set ENTIRE Basic Internal Dialplan to "allow" and
I set ALL OUTBOUND ROUTES to "allow rules" and
outrt-003-7 to "allow" priority 53(outrt-003-7 was a name produced by the system based on my outbound route) All others set to "deny" and all other priorities set to 50.
My only dial rule for the from-tenants custom context is 7|Z.
As with everyone else the context appears not to display after a submit and reload when selected for the extension. I manually changed Context as opposed to selecting under custom contexts dropdown to "from-tenants" just in case.
Assuming it has saved I tested its operation by dialing my mobile from extension 6007 using a 9 to prefix the number to ensure it couldn't dial out on that trunk.

Verbose output from Asterisk as follows

-- Starting simple switch on 'DAHDI/5-1'
-- Executing [9021999999@from-internal:1] Macro("DAHDI/5-1", "user-callerid|SKIPTTL|") in new stack
-- Executing [s@macro-user-callerid:1] Set("DAHDI/5-1", "AMPUSER=4005") in new stack
-- Executing [s@macro-user-callerid:2] GotoIf("DAHDI/5-1", "0?report") in new stack
-- Executing [s@macro-user-callerid:3] ExecIf("DAHDI/5-1", "1|Set|REALCALLERIDNUM=4005") in new stack
-- Executing [s@macro-user-callerid:4] Set("DAHDI/5-1", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:5] Set("DAHDI/5-1", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("DAHDI/5-1", "1?report") in new stack
-- Goto (macro-user-callerid,s,11)
-- Executing [s@macro-user-callerid:11] GotoIf("DAHDI/5-1", "1?continue") in new stack
-- Goto (macro-user-callerid,s,20)
-- Executing [s@macro-user-callerid:20] NoOp("DAHDI/5-1", "Using CallerID "Channel 5" <4005>") in new stack
-- Executing [9021999999@from-internal:2] Set("DAHDI/5-1", "_NODEST=") in new stack
-- Executing [9021999999@from-internal:3] Macro("DAHDI/5-1", "record-enable||OUT|") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("DAHDI/5-1", "1?check") in new stack
-- Goto (macro-record-enable,s,4)
-- Executing [s@macro-record-enable:4] AGI("DAHDI/5-1", "recordingcheck|20090115-124223|1231976534.2151") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck|20090115-124223|1231976534.2151: No AMPUSER db entry for . Not recording
-- AGI Script recordingcheck completed, returning 0
-- Executing [s@macro-record-enable:5] MacroExit("DAHDI/5-1", "") in new stack
-- Executing [9021999999@from-internal:4] Macro("DAHDI/5-1", "dialout-trunk|1|021999999||") in new stack
-- Executing [s@macro-dialout-trunk:1] Set("DAHDI/5-1", "DIAL_TRUNK=1") in new stack
-- Executing [s@macro-dialout-trunk:2] GosubIf("DAHDI/5-1", "0?sub-pincheck|s|1") in new stack
-- Executing [s@macro-dialout-trunk:3] GotoIf("DAHDI/5-1", "0?disabletrunk|1") in new stack
-- Executing [s@macro-dialout-trunk:4] Set("DAHDI/5-1", "DIAL_NUMBER=021999999") in new stack
-- Executing [s@macro-dialout-trunk:5] Set("DAHDI/5-1", "DIAL_TRUNK_OPTIONS=trw") in new stack
-- Executing [s@macro-dialout-trunk:6] Set("DAHDI/5-1", "OUTBOUND_GROUP=OUT_1") in new stack
-- Executing [s@macro-dialout-trunk:7] GotoIf("DAHDI/5-1", "1?nomax") in new stack
-- Goto (macro-dialout-trunk,s,9)
-- Executing [s@macro-dialout-trunk:9] GotoIf("DAHDI/5-1", "0?skipoutcid") in new stack
-- Executing [s@macro-dialout-trunk:10] Set("DAHDI/5-1", "DIAL_TRUNK_OPTIONS=tw") in new stack
-- Executing [s@macro-dialout-trunk:11] Macro("DAHDI/5-1", "outbound-callerid|1") in new stack
-- Executing [s@macro-outbound-callerid:1] ExecIf("DAHDI/5-1", "0|SetCallerPres|") in new stack
-- Executing [s@macro-outbound-callerid:2] ExecIf("DAHDI/5-1", "0|Set|REALCALLERIDNUM=4005") in new stack
-- Executing [s@macro-outbound-callerid:3] GotoIf("DAHDI/5-1", "1?normcid") in new stack
-- Goto (macro-outbound-callerid,s,6)
-- Executing [s@macro-outbound-callerid:6] Set("DAHDI/5-1", "USEROUTCID=") in new stack
-- Executing [s@macro-outbound-callerid:7] Set("DAHDI/5-1", "EMERGENCYCID=") in new stack
-- Executing [s@macro-outbound-callerid:8] Set("DAHDI/5-1", "TRUNKOUTCID="PRIMESOFT"<+6498208272>") in new stack
-- Executing [s@macro-outbound-callerid:9] GotoIf("DAHDI/5-1", "1?trunkcid") in new stack
-- Goto (macro-outbound-callerid,s,12)
-- Executing [s@macro-outbound-callerid:12] ExecIf("DAHDI/5-1", "1|Set|CALLERID(all)=PRIMESOFT<+6498208272>") in new stack
-- Executing [s@macro-outbound-callerid:13] GotoIf("DAHDI/5-1", "1?exit") in new stack
-- Goto (macro-outbound-callerid,s,11)
-- Executing [s@macro-outbound-callerid:11] MacroExit("DAHDI/5-1", "") in new stack
-- Executing [s@macro-dialout-trunk:12] ExecIf("DAHDI/5-1", "0|AGI|fixlocalprefix") in new stack
-- Executing [s@macro-dialout-trunk:13] Set("DAHDI/5-1", "OUTNUM=021999999") in new stack
-- Executing [s@macro-dialout-trunk:14] Set("DAHDI/5-1", "custom=DAHDI/g0") in new stack
-- Executing [s@macro-dialout-trunk:15] ExecIf("DAHDI/5-1", "0|Set|DIAL_TRUNK_OPTIONS=M(setmusic^)tw") in new stack
-- Executing [s@macro-dialout-trunk:16] Macro("DAHDI/5-1", "dialout-trunk-predial-hook|") in new stack
-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("DAHDI/5-1", "") in new stack
-- Executing [s@macro-dialout-trunk:17] GotoIf("DAHDI/5-1", "0?bypass|1") in new stack
-- Executing [s@macro-dialout-trunk:18] GotoIf("DAHDI/5-1", "0?customtrunk") in new stack
-- Executing [s@macro-dialout-trunk:19] Dial("DAHDI/5-1", "DAHDI/g0/021999999|300|tw") in new stack
-- Called g0/021999999
-- DAHDI/1-1 answered DAHDI/5-1
-- Hungup 'DAHDI/1-1'
== Spawn extension (macro-dialout-trunk, s, 19) exited non-zero on 'DAHDI/5-1' in macro 'dialout-trunk'
== Spawn extension (macro-dialout-trunk, s, 19) exited non-zero on 'DAHDI/5-1'
-- Executing [h@macro-dialout-trunk:1] Macro("DAHDI/5-1", "hangupcall|") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("DAHDI/5-1", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("DAHDI/5-1", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("DAHDI/5-1", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("DAHDI/5-1", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("DAHDI/5-1", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("DAHDI/5-1", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'DAHDI/5-1' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'DAHDI/5-1'
-- Hungup 'DAHDI/5-1'

Nowhere is the context "from-tenants" refered to so I'm assuming I have done something that is simple wrong.

Can anyone enlighten me as to what that might be.
Which .conf file to check if the context exists and which .conf file lists it as an include. I'm assuming extensions-???

Cheers


__________________

Greg
Primesoft NZ Ltd


which version number of

fskrotzki's picture

which version number of CustomContexts are you using. Depending on where you downloaded it from it will say the latest but possibly not be. It is always important to state the actual version number instead of "the latest" as somebody a year from might see this have the same problem and the statement of "the latest" does not help them figure things out.

The current latest version is 0.3.4

and the documentation and download for it is at http://www.freepbx.org/support/documentation/module-documentation/third-...


I am using 0.3.4 I would

primesoftnz's picture

I am using 0.3.4
I would have suspected that the verbose asterisk output in a correctly configured system would refer to the custom context I had created (from-tenants) if it was working as designed.
Am I correct in this assumption?


__________________

Greg
Primesoft NZ Ltd


CustomContexts

Bassam's picture

dear all
i'm using FreePBX 2.5.1.0 and could this version support CustomContexts ?
if not which CustomContexts version complay with FreePBX version?

Best Regards,


Bassam, yes it is supported

fskrotzki's picture

Bassam, yes it is supported on 2.5.x


Save Custom Context

mp_leo's picture

Hello I'm using the latest version of FreePBX. If I under "extensions" to "Custom Context" make choices. Is this why not save?


help

mp_leo's picture

I always get this error
Warning: Invalid argument supplied for foreach() in /var/www/asterisk/admin/modules/customcontexts/functions.inc.php on line 494


Are you using version 0.3.4?

wiseoldowl's picture

mp_leo: Make sure you are using version 0.3.4 from here: http://mirror.freepbx.org/modules/release/contributed_modules/


okay i have use but i cant

mp_leo's picture

okay i have use but i cant If I under "extensions" to "Custom Context" make choices. Is this why not save?

My goal is a "device" or "user" to a "route out" to bind.


mp_leo, I was having the

Chilling_Silence's picture

mp_leo, I was having the same issue when I had the Usersets module also installed at the same time as customcontexts.

Have you installed any other custom freepbx modules?


User and device context

pyranetuk's picture

We would also like to be able to create custom contexts for users and devices so that we can lock down the phone when a user isn't logged on.