[Asterisk-Users] My macros, etc.
Kristian Kielhofner
kris at krisk.org
Fri Oct 15 12:42:03 MST 2004
Hey, while we are posting samples, here is what I have worked out: (not
that fancy)
[macro-stdexten]
;${ARG1} - Extension
;${ARG2} - Device(s) to ring
exten => s,1,DBget(USEMUSIC=MOHCaller/${CALLERIDNUM})
exten => s,2,SetMusicOnHold(${USEMUSIC})
exten => s,3,Playback(pls-hold-while-try)
exten => s,4,Dial(IAX2/${ARG2}&SIP/${ARG2}&SIP/${ARG2}2&SIP/${ARG2}3,20,mt)
exten => s,5,Goto(s-${DIALSTATUS},1)
exten => s,102,SetMusicOnHold(default)
exten => s,103,Goto(s,3)
exten => s-NOANSWER,1,Voicemail(u${ARG1})
exten => s-NOANSWER,2,Hangup
exten => s-BUSY,1,Voicemail(b${ARG1})
exten => s-BUSY,2,Hangup
exten => s-CHANUNAVAIL,1,Goto(s-NOANSWER,1)
exten => s-.,1,Goto(s-NOANSWER,1)
exten => a,1,DBget(USERCELL=CellPhone/${ARG1})
exten => a,2,DBget(CELLPIN=CellPIN/${ARG1})
exten => a,3,Authenticate(${CELLPIN})
exten => a,4,SetVar(KKFROMCID=${CALLERIDNUM})
exten => a,5,SetVar(CELLFWD=YES)
exten => a,6,Playback(pls-hold-while-try)
exten => a,7,Macro(voipout,1${USERCELL})
exten => a,102,Goto(s-${DIALSTATUS},1)
exten => a,103,Goto(a,4)
[macro-voipout]
;${ARG1} - number to call
; Uses Cut x2 to extract username from CHANNEL name
; Then looks up the value to set CID
; If no CID, sets CID to 800 in
; Then calls Nufone, VoicePulse
exten => s,1,GotoIf($["${KKFROMCID}" = ""]?2:5)
exten => s,2,Cut(TEMP1=CHANNEL,,1)
exten => s,3,Cut(USERNAME=TEMP1,/,2)
exten => s,4,DBget(KKFROMCID=FromCID/${USERNAME}) ; Get FromCID key
based on username
exten => s,5,SetCIDNum(${KKFROMCID})
exten => s,6,Goto(11)
exten => s,105,SetCIDNum(8003949782)
exten => s,106,Goto(11)
; here we determine which Dial command to use
exten => s,11,GotoIf($["${CELLFWD}" = ""]?12:21)
exten => s,12,NoOp ; NuFone Down
;exten => s,12,Dial(IAX2/${NFLOGIN}@nf-out/${ARG1},,T)
exten => s,13,Dial(IAX2/${VPLOGIN}@vp-out/${ARG1},,T)
exten => s,14,Dial(IAX2/${VPLOGIN}@vp-out1/${ARG1},,T)
exten => s,15,Dial(IAX2/${VPLOGIN}@vp-out2/${ARG1},,T)
; cell phone forward CHANGE THESE IF YOU CHANGE ABOVE
exten => s,21,NoOp ; NuFone Down
;exten => s,21,Dial(IAX2/${NFLOGIN}@nf-out/${ARG1},,A(cellfwd)t)
exten => s,22,Dial(IAX2/${VPLOGIN}@vp-out/${ARG1},,A(cellfwd)t)
exten => s,23,Dial(IAX2/${VPLOGIN}@vp-out1/${ARG1},,A(cellfwd)t)
exten => s,24,Dial(IAX2/${VPLOGIN}@vp-out2/${ARG1},,A(cellfwd)t)
[submenus]
exten => 707,1,Goto(config,s,1)
[config]
exten => s,1,DigitTimeout,5
exten => s,2,ResponseTimeout,10
exten => s,3,Wait(1)
exten => s,4,Background(kc-setpin)
exten => 1,1,Playback(enter-pin)
exten => 1,2,Wait(1)
exten => 1,3,Read(CELLPIN,beep,4)
exten => 1,4,DBPut(CellPIN/${CALLERIDNUM}=${CELLPIN})
exten => 1,5,Goto(3,2)
exten => 2,1,Playback(enter-phone)
exten => 2,2,Wait(1)
exten => 2,3,Read(USERCELL,beep,10)
exten => 2,4,DBPut(CellPhone/${CALLERIDNUM}=${USERCELL})
exten => 2,5,Goto(4,2)
exten => 3,1,DBget(CELLPIN=CellPIN/${CALLERIDNUM})
exten => 3,2,SayDigits(${CELLPIN})
exten => 3,3,Goto(s,1)
exten => 3,102,Playback(nocellpin)
exten => 3,103,Goto(s,1)
exten => 4,1,DBget(USERCELL=CellPhone/${CALLERIDNUM})
exten => 4,2,SayDigits(${USERCELL})
exten => 4,3,Goto(s,1)
exten => 4,102,Playback(nocell)
exten => 4,103,Goto(s,1)
exten => 5,1,DBDel(CellPIN/${CALLERIDNUM})
exten => 5,2,Playback(cellpindelconfirm)
exten => 5,3,Goto(s,1)
exten => 6,1,DBDel(CellPhone/${CALLERIDNUM})
exten => 6,2,Playback(celldelconfirm)
exten => 6,3,Goto(s,1)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup
[intern]
exten => 7000,1,Macro(stdexten,7000,krisk)
As you can see I make extensive use of the * database (maybe MySQL via
ODBC or just MySQL someday). This allows me to set an extensions cell
phone number, customize MOH based on CIDNumber, require a PIN before
forwarding to cellphone, set outbound caller id based on extension, etc.
I don't want to explain everything, so if you want to understand and
can't figure it out let me know. Most of this has just been dialplan
excercise (and impressing friends with *).
--
Kristian Kielhofner
More information about the asterisk-users
mailing list