After hours message

How do I setup my Asterisk Server to give callers and After hours message based on time of the day?
Our office is open 8am-5pm Mon-Fri . I want callers to here a greeting during this time and a different greeting outside these ours. Also want to be able to setup a greeting for Holiday’s .

core show application GotoIfTime.

Here is what I have tried

exten => s,1,Wait(1) exten => s,n,Answer() exten => s,n,WaitExten(2) exten => s,n,Background(4) exten => s,n(replay),GotoIfTime(08:00-17:00,Mon-Fri,*,*?,day) exten => s,n(night),Background(afterhours) exten => s,n,Goto(s,resume) exten => s,n(day),Background(attendant) exten => s,n,WaitExten(5) exten => s,n,Directory(VoiceMail,default) exten => s,n,Playback(dir-first) exten => s,n,Dial(SIP/100,5) exten => s,n,Goto(2) exten => s,n,Hangup()

So this is what I have in my Extensions.conf file How can I get this to work with the after hours message?

;exten => s,1,Wait(1) exten => s,2,Answer() exten => s,3,WaitExten(2) exten => s,4,Background(4) exten => s,5,WaitExten(5) exten => s,6,Directory(VoiceMail,default) exten => s,7,Playback(dir-first) exten => s,8,Dial(SIP/500,5) exten => s,9,Goto(2) exten => s,10,Hangup()

exten => 100,1,Answer()
exten => 100,n,Background(attendant)
exten => 100,n,Goto(default,s,4,3)
exten => 100,n,Goto(default,s,1,3)
exten => 100,n,Goto(default,s,5,3)
exten => 100,n,Goto(default,s,6,3)
exten => 100,n,Goto(default,s,8,5)
exten => 100,n,wait(10)

“,day” should be “:day”.

Also you could use conditional contexts, examples for which are in the sample files.

Does anyone have a working example of the format that works?

lmgtfy.com/?q=asterisk+gotoiftime+example

So all I am trying to do is simply change the attendant message once it is 1700

Our office is open 0800-1700 mon-fri closed weekends

This is what I have trued so far with no avail

;exten => s,1,Wait(1) ;exten => s,n,Answer() ;exten => s,n,WaitExten(2) ;exten => s,n,Background(4) ;exten => s,n,GotoIfTime(09:00-16:00|Mon-Fri|*,*?:day) ;exten => s,n(day),Background(attendant) ;exten => s,n(resume),Wait(1) ;exten => s,n(afterhours),Background(afterhours) ;exten => s,n,Ringing ;exten => s,n,WaitExten(5) ;exten => s,n,Directory(VoiceMail,default) ;exten => s,n,Playback(dir-first) ;exten => s,n,Dial(SIP/400,5) ;exten => s,n,Goto(2) ;exten => s,n,Hangup()

You have a strange mix of “|” and “,” delimiters. I didn’t spot this before because the last delimiter was OK.

exten => s,1,NoOP()
same => n,Answer()
same => n,GotoIfTime(8:00-17:00,mon-fri,,?officehours:closedhours)
same => n(officehours),Background(open-menu)
same => n,Waitexten(10)
same => n,Hangup()
same => n(closedhours),Background(closed-menu)
same => n,WaitExten(10)
same => n,Hangup()

You could also use ExecIfTime but you would need more cases.
same => n,ExecIfTime(0:00-07:59,mon-fri,,?Background(closed-menu))
same => n,ExecIfTime(08:00-17:00,mon-fri,,?Background(open-menu))
same => n,ExecIfTime(17:01-23:59,mon-fri,,?Background(closed-menu))
same => n,ExecIfTime(,sat-sun,,*?Background(closed-menu))

I created these call menu’s will this work

[open]
exten => s,1,Wait(1)
exten => s,n,Answer()
exten => s,n,WaitExten(2)
exten => s,n,Background(attendant)
exten => s,n,WaitExten(5)
exten => s,n,Dial(SIP/400,20)
exten => s,n,Directory(VoiceMail,default)
exten => s,n,Playback(dir-first)
exten => s,n,Dial(SIP/500,5)
exten => s,n,Goto(2)
exten => s,n,Hangup()

[closed] exten => s,1,Wait(1) exten => s,n,Answer() exten => s,n,WaitExten(2) exten => s,n,Background(afterhours) exten => s,n,WaitExten(5) exten => s,n,Dial(SIP/400,20) exten => s,n,Directory(VoiceMail,default) exten => s,n,Playback(dir-first) exten => s,n,Dial(SIP/500,5) exten => s,n,Goto(2) exten => s,n,Hangup()

I wouldn’t call what you wrote a menu as you don’t have any extensions defined for your callers to dial.

I don’t understand why you are using WaitExten before and after your Background. Background will wait for input while it is playing.

I also don’t believe you can return to your dialplan from the Directory application but I may be wrong in this.

Finally your Hangup will never get called as you have created a loop with the Goto 2 above it.

Thanks for all your help I was able to get it going. Again thanks for the sample code that got me on the right track and all is working.