[asterisk-users] Changing contexts "on the fly"
Ade Vickers
javickers at solutionengineers.com
Mon Oct 1 09:21:20 CDT 2007
Hi,
Many thanks all for the useful tips - I've gone with a (simple!) mySQL table
with a flag in it, indicating the day/night mode, adding the following into
the dialplan:
[external]
; other stuff in here, excluded for clarity
; Include the SJS phone line controls
include => sjs_ctrl
[sjs_ctrl]
; Determine if we're in or out of the office, and divert accordingly
; Note - callerID is set because it doesn't get it from the line :(
exten => s,1,NoOp(-- ${CALLERID(number)} calling on ZAP channel)
exten => s,2,Set(CALLERID(number)=unknown)
exten => s,3,Set(CALLERID(name)=SJS Line 1)
exten => s,4,MYSQL(Connect connid db_server login_id super_secret_password
db_name)
exten => s,5,MYSQL(Query resultid ${connid} SELECT\ currentStatus\ FROM\
myStatus)
exten => s,6,MYSQL(Fetch fetchid ${resultid} MyStatus)
exten => s,7,MYSQL(Clear ${resultid})
exten => s,8,MYSQL(Disconnect ${connid})
exten => s,9,GotoIf($[${MyStatus} = y]?10:12)
exten => s,10,GoTo(sjs,s,1)
exten => s,12,Goto(sjs-ooh,s,1)
[sjs]
exten => s,1,NoOp(-- ${CALLERID(number)} calling on ZAP channel)
exten => s,n,Set(CALLERID(number)=unknown)
exten => s,n,Set(CALLERID(name)=SJS Line 1)
exten => s,n,Dial(SIP/5100,30)
exten => s,n,Answer()
exten => s,n,Wait(0.75)
exten => s,n,Voicemail(5100,u)
exten => s,n,Hangup()
[sjs-ooh]
exten => s,1,Answer()
exten => s,n,Wait(0.75)
exten => s,n,Playback(thank-you-for-calling [etc - lots more soundfiles
here])
exten => s,n,Voicemail(5100,s)
exten => s,n,Hangup()
Then, in the internal extensions config, I've added the following:
; Switch SJS day/night modes
;Daytime (star star D)
exten => **3,1,NoCdr()
exten => **3,n,Answer()
exten => **3,n,MYSQL(Connect connid db_server login_id super_secret_password
db_name)
exten => **3,n,MYSQL(Query resultid ${connid} UPDATE\ myStatus\ SET\
currentStatus\ = \ \'n\')
exten => **3,n,MYSQL(Clear ${resultid})
exten => **3,n,MYSQL(Disconnect ${connid})
exten => **3,n,Playback(daytime)
exten => **3,n,Hangup()
;Nighttime (star star N)
exten => **6,1,NoCDR()
exten => **6,n,Answer()
exten => **6,n,MYSQL(Connect connid db_server login_id super_secret_password
db_name)
exten => **6,n,MYSQL(Query resultid ${connid} UPDATE\ myStatus\ SET\
currentStatus\ = \ \'n\')
exten => **6,n,MYSQL(Clear ${resultid})
exten => **6,n,MYSQL(Disconnect ${connid})
exten => **6,n,Playback(nighttime)
exten => **6,n,Hangup()
So I can switch between day & night modes with **D or **N (3 or 6
respectively) :) Dead simple stuff so far, I may get more whizzy with it
later on... At some point, I'll probably switch over to a fully "realtime"
config, so I can DIY my own user interface.
Cheers!
Ade.
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.13.35/1040 - Release Date: 30/09/2007
21:01
More information about the asterisk-users
mailing list