[HELP] Routing by time


#1

Howdy,

I’m not too new to Asterisk, but for a test at where I’m setting up our system, we were trying out routing by time, using the include statement with the | inbetween to determine the time to switch. However I’ve been running into some problems. Firstly, as a look, here is how it looks to start.

------------------- Part of extensions.conf -------------------

[default]
include => internal|9:00-17:00|mon-fri|||
include => nighttime|00:00-8:59|mon-fri|||
include => nighttime|17:01-23:59|mon-fri|||
include => nighttime||sat-sun||*|
include => local
include => longdistance
include => international

[nighttime]
exten => _XXXX,1,Background(tt-weasels)
exten => _XXXX,2,Hangup

[internal]
A bunch of 4 number extensions

------------------------- End of extensions.conf ------------------

So here is my problem. We are using the Wildcard TE410P from Digium, so we have a T1 line going into the back of the box. This T1 line provides us with 50 phone lines, so from XX50 to XX99 (XX is to keep some privacy). The current dialplan (before we even thought of using timing), would have almost all of those 50 extensions used, for testing purposes. So if someone would dial between XXX-XX50 and XXX-XX99, it would automatically go to the extension in the [internal] context, as that was the main context. If someone dialed a number that wasn’t yet defined, they would get the ‘number not in service’ message. So that meant there was 50 different ways to get access to the system, not just a single line. For the future this is something that we really want, as every desk needs their own external number to be reached on, and thus an outside caller is not forced to go through multiple IVR’s to reach one of the many hundred employees.

However we wanted to implement the timing scheme, so it would play different messages. So our first one was simply the following lines

----------- Old timing test ---------

[default]
include => internal|9:00-17:00|mon-fri|||
include => nighttime
include => local
include => longdistance
include => international

[nighttime]
exten => s,1,Background(tt-weasels) ; as a joke test

[internal]
nothing changed at all


That would work fine during the daytime hours, but however when it reached the nighttime portion, dialing any extension that belonged to our T1 line would not go through, and an error in the Asterisk CLI would say that the extension does not exist in the given context. Which is entirely true, as the extension being dialed did not exist in the nighttime context. That was when we added the

exten => _XXXX,1,Background(tt-weasels)
exten => _XXXX,2,Hangup

lines to [nighttime] so that it would play the message after hours, because all extensions coming in are 4 digits long. However this caused a bit of a problem, because we want it so that if someone dials an extension that is not currently setup as anything in the internal context (say XX94), it would still give them the ‘not in service’ error. However that wasn’t happening, as they would always get the weasels message, because that would catch any extension.

So that brings us to the current set up at the top. If someone calls during hours, and are calling a valid extension, it will go through. If they are calling during hours, and call an invalid extension, they get the ‘not in service’ error. If they call a valid extension after hours, they get the weasels message. However if they call an invalid extension after hours, they still get the weasels message. I do not want that last one to happen. If they ever call an invalid extension, I want them to get the ‘not in service’ error.

So after that lengthy and probably over-worded description, does anyone think they can help me out? Given the examples from voip-info.org and such, it looks like they are designed for a single line system (not a T1 that has 50 different numbers per connection). Has anyone with a T1 or an E1 set this up yet and think they can help me? I’ve tried calling Digium, however their current system is borked (ironically it’s an Asterisk system, and it’s currently down, or the extension for their help number has been changed).

Any help would be appreciated.

Cheers,
Moody


#2

As you say, it’s a long description, and my understanding of it may not be quite right. But, to me, it looks like you’ve got your logic wrong. The way you’ve got it set up, it can’t do anything other than what it does - well, i suppose that much is obvious, anyway! :wink:

You’re not checking for valid extensions in your nighttime context, so everything goes to the only place it can - the out of service message.

You’ll need to include the same “A bunch of 4 number extensions” lines in the nighttime context too - but instead of dialling the relevant phone, it plays that message and hangs up. The fall-through would be an “invalid extension” message.

I’ve never checked out how you do different things at different times in asterisk, but it occurs to me that perhaps a better way to approach this problem would be do define a macro that checks what time of day/week it is and then either dials {EXTEN} or plays the out of hours message and hangs up. Then in each extension definition, you reference this macro, rather than dial or whatever.

I’ve never really checked out how asterisk macros work either, so i don’t know how you’d implement this. But that seems like a logical approach to me.


#3

[quote=“WillKemp”]As you say, it’s a long description, and my understanding of it may not be quite right. But, to me, it looks like you’ve got your logic wrong. The way you’ve got it set up, it can’t do anything other than what it does - well, i suppose that much is obvious, anyway! :wink:

You’re not checking for valid extensions in your nighttime context, so everything goes to the only place it can - the out of service message.

You’ll need to include the same “A bunch of 4 number extensions” lines in the nighttime context too - but instead of dialling the relevant phone, it plays that message and hangs up. The fall-through would be an “invalid extension” message.

I’ve never checked out how you do different things at different times in asterisk, but it occurs to me that perhaps a better way to approach this problem would be do define a macro that checks what time of day/week it is and then either dials {EXTEN} or plays the out of hours message and hangs up. Then in each extension definition, you reference this macro, rather than dial or whatever.

I’ve never really checked out how asterisk macros work either, so i don’t know how you’d implement this. But that seems like a logical approach to me.[/quote]

I had actually looked into doing the macro idea. It seems to be the only one that will fit in this situation.

Cheers,
Moody