Configuring the dialplan

Assume we have a work schedule below
Sunday: Off Work
Monday: 13:00 – 13:50
Tuesday: 11:00 – 13:50
Wednesday: Off Work
Thursday: 11:00 – 13:50
Friday: Off Work
Saturday: Off Work

We could then create conditions to send the phone system to the after hours voicemail when we are not at working using the following GotoIfTime() settings in the [phones] context of the /etc/asterisk/extensions.conf file:

exten => 100,1,NoOp(Call for matthew)
same => n,GotoIfTime(*,wed&fri-sun,*,*?phones,199-afterhours,1)
same => n,GotoIfTime(0:00-12:59&13:51-23:59,mon,*,*?phones,199-afterhours,1)
same => n,GotoIfTime(0:00-10:59&13:51-23:59,tue&thu,*,*?phones,199-afterhours,1)
same => n,Dial(SIP/matthew,5)
same => n,Hangup

We will also need to add the new extension that will call the after-hours voicemail within the [phones] context.

exten => 199-afterhours,1,NoOp(After hours voicemail)
same => n,VoiceMail(199@default)
same => n,Hangup

 

We will also need to create the voicemail box of the afterhours account. Add the following to the [default] context of the /etc/asterisk/voicemail.conf:
199 => 199,afterhours,[email protected]