There’s several options to take when implementing it to the dial plan. There’s an AGI script similar to voip-info.org/wiki/view/Aste … +openhours, database putting / getting, GotoIfTime, etc. Anyone want to share their experiences with holiday implementations?
In my opinion, the AGI script looks to be the most straight forward and most manageable (especially when a year or two passes and I forget the syntax).
I’ve been porting over an old 1.0 dialplan, and since I was rewriting everything in AEL anyway I decided to try this as well (previously used context includes in 1.0). I’m still working the kinks out of the prompts themselves (timeouts etc.), but the open/closed calculations are working fine.
I don’t know how efficient this is, but it was straightforward to code and easy to maintain.
[code]context mainmenu-HQ {
0 => goto mainmenu-HQ|s|1;
2 => {
if (${hq_holiday} = yes) NoOp();
if (${is_hq_open} = no) NoOp();
if (${is_hq_open} = yes) goto sales-HQ|s|1;
}
3 => {
if (${hq_holiday} = yes) NoOp();
if (${is_hq_open} = no) NoOp();
if (${is_hq_open} = yes) goto support-HQ|s|1;
}
4 => {
if (${hq_holiday} = yes) NoOp();
if (${is_hq_open} = no) NoOp();
if (${is_hq_open} = yes) &std-exten-HQ(3114,“SIP”);
}
5 => {
if (${hq_holiday} = yes) NoOp();
if (${is_hq_open} = no) NoOp();
if (${is_hq_open} = yes) &std-exten-HQ(3204,“SIP”);
}
=> {
if (${hq_holiday} = yes) NoOp();
if (${is_hq_open} = no) NoOp();
if (${is_hq_open} = yes) goto mainmenu-HQ|s|repeat;
}
s => {
// by default we are closed
hq_holiday=no;
is_hq_open=no;
// normal business hours, and if
// we ain't open, we're closed.
ifTime (09:00-17:59|mon-fri|*|*) is_hq_open=yes;
else is_hq_open=no;
ifTime (*|*|1|jan) {
hq_holiday=yes; // New Year's Day
is_hq_open=no;
}
ifTime (*|*|4|jul) {
hq_holiday=yes; // Independence Day
is_hq_open=no;
}
ifTime (15:00-23:59|*|3|sep) {
hq_holiday=yes; // Labor Day
is_hq_open=no;
}
ifTime (*|*|22|nov) {
hq_holiday=yes; // Thanksgiving
is_hq_open=no;
}
ifTime (17:00-23:59|*|23|nov) {
hq_holiday=yes; // Black Friday
is_hq_open=no;
}
ifTime (15:00-23:59|*|24|dec) {
hq_holiday=yes; // Christmas Eve
is_hq_open=no;
}
ifTime (*|*|25|dec) {
hq_holiday=yes; // Christmas Day
is_hq_open=no;
}
ifTime (16:00-23:59|*|31|dec) {
hq_holiday=yes; // New Year's Eve
is_hq_open=no;
}
if (${is_hq_open} = yes) {
Ringing();
Wait(1);
Set(attempts=0);
Answer();
Wait(1);
Set(TIMEOUT(digit)=5);
Set(TIMEOUT(response)=15);
Background(HQ-sounds/thank-you-for-calling);
WaitExten(0.3);
repeat:
Set(attempts=$[${attempts} + 1]);
Background(HQ-sounds/hq-mainmenu-list);
Background(HQ-sounds/menu-again-press-pound);
WaitExten(10);
if (${attempts} < 4) goto repeat;
Background(vm-goodbye);
Hangup();
}
else if (${hq_holiday} = yes) {
Ringing();
Wait(1);
Set(attempts=0);
Answer();
Wait(1);
Set(TIMEOUT(digit)=5);
Set(TIMEOUT(response)=15);
repeatholiday:
Background(HQ-sounds/office-closed-holiday);
Set(attempts=$[${attempts} + 1]);
WaitExten(5);
if (${attempts} < 2) goto repeatholiday;
Background(vm-goodbye);
Hangup();
}
else {
Ringing();
Wait(1);
Set(attempts=0);
Answer();
Wait(1);
Set(TIMEOUT(digit)=5);
Set(TIMEOUT(response)=15);
repeatclosed:
Background(HQ-sounds/office-closed);
Set(attempts=$[${attempts} + 1]);
WaitExten(5);
if (${attempts} < 2) goto repeatclosed;
Background(vm-goodbye);
Hangup();
}
}
i => Playback(HQ-sounds/invalid-extension);
};
[/code]