Asterisk day night mode example

This example shows you a simple way to have a day and night mode that will automatically switch baised on the current system time.
In this example, I assume 4710 is our MAIN DID extension. Extension 521 is the reception desk extension number. We use a gotoiftime statement to see if we should go to the prompt or if we should continue on to dialing the reception extension. The 4710 would be replaced with the S extension if you are working with analog lines.


exten => 4710,1,GotoIfTime(17:00-8:59|*|*|*?night-mode|1) ;break at night send directly to message otherwise just continue and dial
exten => 4710,2,GotoIfTime(12:00-12:59|*|*|*?night-mode|1);break for lunch
exten => 4710,3,Dial(Sip/521,15,tr)
exten => 4710,4,Goto(night-mode,1)

exten => night-mode,1,Answer
exten => night-mode,2,Wait(2)
exten => night-mode,3,SetMusicOnHold(default)
exten => night-mode,4,DigitTimeout,3
exten => night-mode,5,ResponseTimeout,20
exten => night-mode,6,Background(/astsounds/p1)
exten => night-mode,7,SetVar(LISTCOUNT=$[${LISTCOUNT} + 1]) ; increment
exten => night-mode,8,WaitExten(8)
exten => night-mode,9,GotoIf($["${LISTCOUNT}" >= "0"]?0,1:3)
exten => night-mode,10,Background(pls-wait-connect-call)
exten => night-mode,11,Goto(0)

; 0 Forwards caller to receptionist
exten => 0,1,Playback(pls-wait-connect-call)
exten => 0,2,Dial(Sip/510,30,m)
exten => 0,3,Voicemail(u510)
exten => 0,104,Voicemail(u510)

original article can be found here

Night Service Button

This alternate example presents an Asterisk 1.6.1 example that works more like a traditional button toggle, based on AEL and using ASTDB that provides BLF lamp updates for a Snom 320 with firmware 7.3.14. If you are using snom you should follow the instructions at to ensure that your BLF subscriptions are successful. Following that you should set the spare function on your snom to subscribe to your Night service phantom DN.

Simply read DB(service/daynight) to act on it in your dialplan.


context nightservice { // You must include this in your relevant internal context in extensions.conf

// assuming 7702 is the Custom phantom DN for your night service lamp

hint(Custom:7702) 7702 => {
// Day service / night service toggle
SayDigits(1); // Change this to a suitable prompt


macro setServiceMode(mode,blfDevice) {
Verbose(BLF DEVICE: ${blfDevice});
switch(${mode}) {
case D: //day
case 3: // keypad button for D
Set(BLF=NOT_INUSE); // lamp off
case N: //night
case 6: // keypad button for N
Set(BLF=BUSY); // lamp on solid
case L: //Lunch
case 5: // keypad button for L
Set(BLF=ONHOLD); // lamp flashing
Verbose(BLF Setting: ${BLF});

Created by: zraytechnologies, Last modification: Fri 05 of Nov, 2010 (09:50 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+