[asterisk-users] Dailplan code for holiday detection?

Daniel Hazelbaker daniel at highdesertchurch.com
Tue Dec 23 16:08:00 CST 2008


We chose to use a mySQL database to store the holiday information.   
When a call is answered we query the database to see if there is a  
"holiday" greeting recorded, if so we play the indicated greeting,  
otherwise play the "default" menu greeting. (We do our dialplans in AEL)


context checkHoliday {
         s =>
           {
            	begin:

                 MYSQL(Connect temp communicator username password  
asterisk);
                 MYSQL(Query resultid ${temp} SELECT greeting FROM  
menuGreetings WHERE startTime<=FROM_UNIXTIME(${EPOCH}) AND  
endTime>=FROM_UNIXTIME(${EPOCH}) LIMIT 1);
                 MYSQL(Fetch foundRow ${resultid} sqlGreeting);
                 MYSQL(Clear ${resultid});
                 MYSQL(Disconnect ${temp});

                 if ("${foundRow}"=="1")
                 {
                         Background(custom/mainMenu/${sqlGreeting});
                         goto mainMenu,s,begin;
                 }
                 else
                 {
                         goto checkTime,s,begin;
                 }
         }
         includes
           {
            	mainMenu;
                 tempGreeting;
                 voicemail;
                 publicExt;
         }
};


The 'checkTime' context simply checks if we are open or closed and  
plays the appropriate greeting (if no holiday greeting is found).

Daniel

On Dec 23, 2008, at 1:14 PM, Scott L. Lykens wrote:

> Not the most elegant but since I have a generic context for my IVRs I
> simple check the date there.
>
> exten => s,n,GotoIfTime(*|*|1|jan?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|10|apr?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|25|may?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|3|jul?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|7|sep?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|26|nov?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|27|nov?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|25|dec?closed-holiday|1)
> exten => s,n,GotoIfTime(*|*|26|dec?closed-holiday|1)
>
> exten =>
> closed-holiday,1,Background(ivr-closed-holiday-${AUTOATTENDANT}||)
> exten => closed-holiday,n,Hangup
>
> This is next year's holidays for us but with this year's Christmas  
> days
> in it.
>
> sl
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>




More information about the asterisk-users mailing list