FreePBX Paid Support


Not Logged in - No Account?

Don't have an account? Registering an account with us allows you to post to the forums, easily track new posts, subscribe to threads, pm (private message) other forum members, and receive periodic news letters (you can opt out if you desire). Once you are logged in this message will no longer appear. If you don't have an account, you can create one by registering here. Lost your password, request a new password. We respect your privacy which means we collect minimal information when you register and we do not resell that information or use it in any objectionable way. You can review our privacy policy for full details.


Extension with Time Conditions?

wnpaul's picture

I am in the process of setting up a PBX for a school where DDI calls to classroom extensions should land at the switchboard during school hours, but go through to the extension at other times.

Can someone point me to some documentation on how to do this, preferably using the FreePBX Gui but if it requires editing a custom config file that would be also o.k. -- I expect this configuration to be pretty static.


__________________

Wolf N. Paul
wnp@doulos.at


Comment viewing options

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

You should be able to do

jmullinix's picture

You should be able to do this with Time conditions. You will need to point the inbound route to a time condition that rings the switchboard during normal hours and rings the extension otherwise. I think this would be pretty straightforward to set-up in the Web Gui.


__________________

John Mullinix, Cohutta.Com, Inc.
1-706-632-3343 -- sip://17066323343@qth.cohutta.org
Looking for Dundi peers in Baltimore, MD and Lake Wales, FL USA


Yes - but for each extension

Bitnetix's picture

If you take this approach that John says (which will work), you'll need to program that for each DID. So if you have 100 DIDs that would normally ring to 100 different extensions, then you'll have to create 100 different internal routes and 100 different time conditions.

Do your DIDs map to extension numbers? Meaning, does NXX1234 map to extension 1234?


__________________

www.bitnetix.com - info@bitnetix.com - 877.33.VOICE - sip://bitnetix@bitnetix.com


Each extension needs an inbound route

tomsyr's picture

If you have DID's, then they would all have to have their own route - so thinking in reverse - How about a time condition of 'All calls between 8-5 mon-fri' go to XXXX (the switchboard), then use the specific DID routes for the 'off hours'.


it's a useful feature

p_lindheimer's picture

it's a useful feature request to enter into the system if this is a common issue, basically a destination that can be set against a timegorup that can then have any number of inbound routes link to, so if the condition is met (or not met, which ever logic you choose) anything linked to that goes to that destination, otherwise it goes to their already defined destination. Such feature requests need to go into the tracker or they will be quickly forgotten.


__________________

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


This might not be too hard

jmullinix's picture

This might not be too hard to implement with a line or two of custom code.

If your trunk is in the from-trunk or from-pstn context place a section in extensions_custom.conf called "from-pstn-custom" and add a line of code similar to this:

[from-pstn-custom]
exten => _XXX.,1,GotoIfTime(time range|days of week|days of month|months?[[context|]extension|]pri)

In practice this might look like

[from-pstn-custom]
exten => _XXX.,1,GotoIfTime(9:00-17:00|mon-fri|*|*?ivr-3,s,1)

This will match any DID that has at least 4digits and test that call for the time. If the time matches, in this case 9-5 daily, it will send all calls to ivr-3. If it fails the time test, it will fall on through to the normal call routing, which in your case would be the DID match and off to an extension.

HTH,


__________________

John Mullinix, Cohutta.Com, Inc.
1-706-632-3343 -- sip://17066323343@qth.cohutta.org
Looking for Dundi peers in Baltimore, MD and Lake Wales, FL USA


Thank you!

wnpaul's picture

Thank you very much for that last example; that looks easy enough to implement.

Now if you would also have a suggestion where next to look for my Incoming Calls problem ( http://www.freepbx.org/forum/freepbx/users/incoming-calls-on-sip-trunk-4... ) ... can't turn off the telco line for the voip line until I can receive calls over it.

Wolf


__________________

Wolf N. Paul
wnp@doulos.at


If you want to keep working

p_lindheimer's picture

If you want to keep working properly, you are probably going to need something more like this I believe:

[from-pstn-custom]
exten => _XXX.,1,GotoIfTime(9:00-17:00|mon-fri|*|*?ivr-3,s,1)
exten => _XXX.,n,Goto(ext-did,${EXTEN},1)

Otherwise it will not find anything else in the from-pstn-custom context and then fail outside of that time (at least with some asterisk configs as I think this behavior has been changing somewhat with 1.4 depending on certain config options). The assumption above is that all the dids are defined, as it will circumvent from-did-direct and ext-did-catchall.

So ... in the long term, if there is enough interest (or bribes) a module that hooks into inbound routes, allowing a single destination to be specified for multiple routes by time would be the right way to go. (And then daynight able to hook into it like has been enabled with timeconditions on 2.5 to override one or multiple time conditions with a single daynight override would be even better.)


__________________

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


Philippe, I have some custom

jmullinix's picture

Philippe,

I have some custom code in from-pstn-custom and I don't have a return route at the end of it. Here Tiz:

[from-pstn-custom]

exten => 6419621634,1,Answer()
exten => 6419621634,n,noop(It is in From PSTN custom)
exten => 6419621634,n,wait(2)
exten => 6419621634,n,senddtmf(1|1000)

I use this code to send a dtmf 1 to trick my Grand Central number into thinking I have pressed one. Note that I do not have a return route. I think because the call to "from-pstn-custom" is actually an include, it return to the next command after the include. At least, this is the behavior I have observed. Let me know if I am off base here, but it works on my box.


__________________

John Mullinix, Cohutta.Com, Inc.
1-706-632-3343 -- sip://17066323343@qth.cohutta.org
Looking for Dundi peers in Baltimore, MD and Lake Wales, FL USA


John, I think this is new

p_lindheimer's picture

John,
I think this is new behavior in 1.4 and I'm not sure if it is configurable or not. I do not think it is the same in 1.2 although I am not certain. Here is an example test to understand the behavior:

[tst-1]
exten => 9123,1,Noop(tst-1 - 1)
exten => 9123,n,Noop(tst-1 - 2)

[tst-2]
exten => 9123,1,Noop(tst-2 - 1)
exten => 9123,n,Noop(tst-2 - 2)
exten => 9123,n,Noop(tst-2 - 3)

[tst-3]
exten => 9123,1,Noop(tst-3 - 1)
exten => 9123,n,Noop(tst-3 - 2)
exten => 9123,n,Noop(tst-3 - 3)
exten => 9123,n,Noop(tst-3 - 4)

[from-internal-custom]
include => tst-1
include => tst-2
include => tst-3

Now dial 9123 and you will get:

    -- Executing [9123@from-internal:1] NoOp("SIP/222-b7501c28", "tst-1 - 1") in new stack
    -- Executing [9123@from-internal:2] NoOp("SIP/222-b7501c28", "tst-1 - 2") in new stack
    -- Executing [9123@from-internal:3] NoOp("SIP/222-b7501c28", "tst-2 - 3") in new stack
    -- Executing [9123@from-internal:4] NoOp("SIP/222-b7501c28", "tst-3 - 4") in new stack
    -- Executing [9123@from-internal:5] Wait("SIP/222-b7501c28", "1") in new stack
    -- Executing [9123@from-internal:6] Congestion("SIP/222-b7501c28", "20") in new stack

So note it will fall through and look for the next priority in the next include, meaning you have to be very careful because as you can see, [tst-2] does not have it's priority 1 or 2 executed and [tst-3] does not have it's first 3 executed.


__________________

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


Wolf, sorry for hijacking

jmullinix's picture

Wolf, sorry for hijacking the thread.
Philippe, I am glad we hijacked this thread. If I had done this, I would never had figured it out. Thanks for the insight.

In Wolf's case, your way would be the correct way. I usually use this to trap something and if it does trap it, then process the call normally. I need to modify my code also.

Thanks and have a great day. Suppertime here.


__________________

John Mullinix, Cohutta.Com, Inc.
1-706-632-3343 -- sip://17066323343@qth.cohutta.org
Looking for Dundi peers in Baltimore, MD and Lake Wales, FL USA


No Problem!

wnpaul's picture

I don't mind this hijacking -- I learned things from this.

Wolf


__________________

Wolf N. Paul
wnp@doulos.at