Asterisk voicemail on specific time range

Hello, is there a way to set asterisk voice mail to turn on, in specific time range ?

ex: Asterisk voicemail turns on from 23:00 to 8:00

With just Asterisk I’m not aware of a setting for that…

But, in the dialplan you could handle it by just not executing the voicemail line in the period you don’t want voicemail.

For instance…


exten => 123,1,macro(dial,SIP/123)

[macro-dial]
exten => s,1,NoOp(macro-dial ${ARG1})
exten => s,n,Dial(${ARG1},20)
exten => s,n,GotoIfTime(8:00-16:45|Mon-Fri|*|*?:novm)
exten => s,n,VoiceMail(${MACRO_EXTEN}@default,u)
exten => s,n(novm),NoOp()

I’ve done it by that way:


[default]
exten=>1000,1,Goto(internal,1000,1)
exten=>2000,1,GotoIfTime(18:00-9:00|mon-fri|*|*?voicemail,2000,1)
exten=>2000,2,GotoIfTime(:9:00-18:00|mon-fri|*|*?internal,2000,1)
exten=>2000,3,GotoIfTime(*|sat-sun|*|*?weekend,2000,1)

[internal]
exten=>1000,1,Dial(SIP/1000)
exten=>2000,1,Dial(SIP/2000)


[voicemail]
exten=>2000,1,Dial(SIP/2000, 10)
exten=>2000,2,VoiceMail(2000@2000)
exten=>2000,3,PlayBack(vm-goodbye)
exten=>2000,4,Hangup()

I have added voicemail for number 2000. If the time is in the range 18:00 - 9:00 the voice mail will turn on and if the time is in the range 9:00 - 18:00 the voicemail will not turn on. For Sat and Sun the voice mail will work non stop. It’s just a test conf but it worked fine :smile: