<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; "><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> Warren Selby <<a href="mailto:wcselby@selbytech.com">wcselby@selbytech.com</a>><br><span style="font-weight:bold">Reply-To: </span> Asterisk Users Mailing List - Non-Commercial Discussion <<a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a>><br><span style="font-weight:bold">Date: </span> Mon, 21 Mar 2011 20:37:52 -0500<br><span style="font-weight:bold">To: </span> Asterisk Users Mailing List - Non-Commercial Discussion <<a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a>><br><span style="font-weight:bold">Subject: </span> Re: [asterisk-users] Play different voice-mail messages based on certain conditions<br></div><div><br></div><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div class="gmail_quote">On Mon, Mar 21, 2011 at 8:05 PM, Harel Cohen <span dir="ltr"><<a href="mailto:harel@easycall.gi">harel@easycall.gi</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-GB"><div><p class="MsoNormal"><span style="color: rgb(0, 0, 102); font-family: Cambria, serif; ">Hello List,</span></p><p class="MsoNormal"><span style="color: rgb(0, 0, 102); font-family: Cambria, serif; ">I have few installations out there based on 1.6.1 or above.</span></p><p class="MsoNormal"><span style="color: rgb(0, 0, 102); font-family: Cambria, serif; ">I’m trying to play different voice mail messages based on certain criteria’s. For example, I want during office hours to play (in short): “we are not available to take your call, please leave a message”, during off-hours and weekends I would play: “we are closed, our opening hours xx:xx-yy:yy, please leave a message or send a fax or send an email” and during holidays I would play: “we are closed due to holiday, please leave a message, fax, blab la” etc.</span></p><br clear="all"></div></div></blockquote></div><br>What I have done for various clients in your situation is to create conditional contexts based on either time of day and day of year criteria (see GotoIfTime()[1]) and then use Playback() to play the correct voicemail greeting, then call the Voicemail() app with just the s option, which skips all "vm-intro"'s and any pre-recorded messages. <br><br>Quick, off the top of my head example:<br><br>[default]<br>exten => _X.,1,Verbose(Incoming call - battlestations!)<br>exten => _X.,n,Answer()<br>exten => _X.,n,Dial(SIP/${EXTEN},30)<br>exten => _X.,n,Verbose(No one answered - going to voicemail)<br>
exten => _X.,n,Goto(no-answer,s,1)<br><br>[no-answer]<br>; no one answered, play voicemail based on time of day / day of year<br>exten => s,1,Verbose(Checking time conditions to play proper voicemail)<br>exten => s,n,Verbose(First check holidays)<br>
exten => s,n,GotoIfTime(*,*,25,dec?holiday,1) ; Christmas, add your own here<br>exten => s,n,Verbose(Not a holiday - so checking time of day)<br>exten => s,n,GotoIfTime(08:00-18:00,mon-fri,*,*?officehours,1)<br>exten => s,n,Verbose(Time condition check failed - playing after-hours message)<br>
exten => s,n,Goto(afterhours,1)<br><br>; holiday voicemail greeting<br>exten => holiday,1,Verbose(Playing holiday greeting)<br>exten => holiday,n,Playback(holiday-greeting)<br>exten => holiday,n,Voicemail(defaultmailbox@default,s)<br>
exten => holiday,n,Hangup()<br><br>; officehours voicemail greeting<br>exten => officehours,1,Verbose(Playing officehours greeting)<br>exten => officehours,n,Playback(officehours-greeting)<br>exten => officehours,n,Voicemail(defaultmailbox@default,s)<br>
exten => officehours,n,Hangup()<br><br>; afterhours voicemail greeting<br>exten => afterhours,1,Verbose(Playing afterhours greeting)<br>exten => afterhours,n,Playback(afterhours-greeting)<br>exten => afterhours,n,Voicemail(defaultmailbox@default,s)<br>
exten => afterhours,n,Hangup()<br><br><br>[1]: <a href="http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIfTime">http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIfTime</a><br><br>-- <br>Thanks,<br>--Warren Selby, dCAP<br><a href="http://www.selbytech.com" target="_blank">http://www.selbytech.com</a><br></blockquote></span><div><br></div><div><div><div>I used a slightly different approach – below is a snippet of my [day-menu] context that I did for one of my installs. I load up the site's holiday schedule in the Asterisk data base (I do it once per year, and train someone to do it if I cannot), then check for the current date/holiday key – if it is =1 then I play out the holiday greetings, otherwise I play out the day or night greeting. The second argument to STRFTIME is the time zone – be sure to get that right for your installation.</div><div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">[day-menu]</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,1,Answer()</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Wait(1.5) ; Wait for callerID spill</span></font></span></div><div style="font-family: Consolas; "><font class="Apple-style-span" face="Courier" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Set(DATE=${STRFTIME(${EPOCH},ChST,%C%y%m%d)})</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Verbose(2,---> Current date is ${DATE})</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(reinit),Set(COUNTER=0)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,GotoIf($["${DB(custom/${DATE}/holiday)}" = "1"]?holiday)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Goto(daycheck)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(holiday),Set(MENU=holiday-menu)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Goto(playmenu)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(daycheck),GotoIfTime(08:00-16:59,mon-fri,*,*?open)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Set(MENU=night-menu)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Goto(night)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(open),Set(MENU=day-menu)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(night),NoOp()</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(top),Wait(0.5)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,GotoIf($[${COUNTER}>=10]?wrong)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(playmenu),Background(${MENU})</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(bypass),WaitExten(10)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">; go straight to VM if they time out...</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Goto(2,1)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n(wrong),Playback(something-terribly-wrong)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Playback(goodbye)</span></font></span></div><div style="font-family: Consolas; "><span style="font-family: Courier; "><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px;">exten => s,n,Hangup()</span></font></span></div></div><div><div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font></div></div></div></div></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;">Hopefully this is enough to get you started.</span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;">Cassius Smith</span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font></div></body></html>