login | register
Sat 06 of Sep, 2008 [16:59 UTC]

voip-info.org

History

Asterisk tips openhours

Created by: oej,Last modification on Wed 13 of Aug, 2008 [17:39 UTC] by kue

How to include contexts based on time and date

The Asterisk dial plan, extensions.conf lets you include contexts based on time and/or date.

Syntax:

include => context|<times>|<weekdays>|<mdays>|<months>

Syntax for Asterisk 1.6

As of Asterisk 1.6-Beta and Trunk (with an uncertain start date) the delimiter has changed to the comma (',').
Stumbled across this after my dialplan would not work in 1.6 or trunk.

For example, the syntax should be....

include = day,08:00-16:59,mon-fri,*,*

Example:

; First, let's do the holidays
include => holiday|*|*|1|jan
include => holiday|*|*|31|may
include => holiday|*|*|4|jul
include => holiday|*|*|6|sep
include => holiday|17:00-23:59|*|24|nov
include => holiday|*|*|25|nov
include => holiday|17:00-23:59|*|24|dec
include => holiday|*|*|25|dec
include => holiday|17:00-23:59|*|31|dec

; these are the days we're open
include => day|09:00-19:59|mon-fri|*|*
include => day|10:00-14:59|sat|*|*

; if we're not open, we're closed (duh!)
include => night

Example from Troy Settle


I ran into a problem with this. The night context is always included in this scenario, and if the night context contains the same extensions as the day context, Asterisk will continue with the night context if the extensions match:

[day]
exten => s,8,Background(to-hear-meu-again)

will jump to:
[night]
exten => s,9,Background()

To prevent this, specify an explicit night include:
include => night|20:00-8:59|mon-fri|*|*
include => night|15:00-9:59|sat|*|*
include => night|*|sun|*|*



Comments

Comments Filter
222

333

by forsen, Friday 09 of May, 2008 [13:29:14 UTC]
My office is closed entiry july, and according to the example above, you need to include both "open" and "closed".

In that case, it would look something like this:

include => inbound-closed|*|*|*|jul
include => inbound-open|*|*|*|aug
include => inbound-open|*|*|*|sep
etc
etc

Isn't there some other way to do it?

like:

include => inbound-closed|*|*|*|jul
include => inbound-open|*|*|*|!jul

Would have been nice.

222

333Not working after server restart / weekend

by parleer, Monday 11 of December, 2006 [16:30:00 UTC]
I am doing the following:

include => inbound-open|8:00-17:00|mon-fri|*|*
include => inbound-closed|17:01-7:59|mon-fri|*|*
include => inbound-closed|*|sat|*|*
include => inbound-closed|*|sun|*|*

This works Mon-Fri, at 5:01 PM Asterisk uses the "closed" context, and the next morning at 8:00 AM it uses the "open" context. This also works correctly all weekend, using the "closed" context throughout. However, every Monday morning at 8:00 AM it does NOT start using the "open" context again. Inevitably, we end up having to run "/etc/rc.d/init.d/asterisk restart". After that it works correctly. Any ideas?
222

333Time zone

by ajhoughton, Friday 07 of July, 2006 [16:08:46 UTC]
What time zone is used for this feature? Is it the local time of the server? If so, how does one go about specifying some other time zone? (For instance, if---like me---you have two offices, in different countries, to worry about)?