All pastes #394 Raw Edit

blitzrage

public text v1 · immutable
#394 ·published 2004-08-01 22:00 UTC
rendered paste body
This script looks for the (channel)/(extension) match from the database.

For an extension 100 using SIP and a followme number of 123-456-7890

database put 100 LOCAL SIP/100
database put 100 FOLLOW 1234567890

${TRUNKLD} needs to be set to whatever your outgoing LD provider is

[macro-stdexten]
; exten => <ext>,<pri>,Macro(stdexten,<number>,<CID>)
exten => s,1,SetCallerID(${ARG2})                                       ; set CallerID Name and Number
exten => s,2,DBGet(EXT=${ARG1}/LOCAL)                                   ; retreive local channel/extension
exten => s,3,NoOp(Local channel/extension for this call: ${EXT})        ; output the value from the database
exten => s,4,DBGet(FOLLOW=${ARG1}/FOLLOW)                               ; retreive follow me number (possibly null)
exten => s,5,NoOp(Follow me number (possibly NULL): ${FOLLOW})          ; see what the follow me number is
exten => s,6,Dial(${EXT},15,t)                                          ; attempt to call the channel/extension
exten => s,7,GotoIf($[${DIALSTATUS} = BUSY]?s-BUSY)                     ; if busy, just go straight to voicemail
                                                                        ; (don't bother us, we're busy)
exten => s,8,GotoIf($[foo${FOLLOW} = foo]?s-${DIALSTATUS}|1:followme|s|1)       ; If ${FOLLOW} is NULL, Goto s-${DIALSTATUS}
                                                                        ; else Goto followme,s,1 (because we have a number
                                                                        ; that we can try before going to voicemail)
exten => s-NOANSWER,1,Voicemail(u${ARG1})                               ; if no answer, play voicemail unavail of extension
exten => s-BUSY,1,Voicemail(b${ARG1})                                   ; if busy, play voicemail busy of extension

[followme]
; used from the stdexten macro for follow me service.
exten => s,1,ResponseTimeout(${DEFAULT_TIMEOUT})        ; response timeout of (DEFAULT) seconds
exten => s,2,Wait(1)                                    ; wait 1 second
exten => s,3,Cut(EXT=EXT,/,2)                           ; Cut the EXT variable so that we just get the extension number
exten => s,4,Background(hacklocalhost-vm-or-cell)       ; *** Custom prompt *** "Press 1 for voicemail or 2 to try that
							; this persons follow me line" (or something like that)
exten => 1,1,Voicemail(u${EXT})                 ; extension number as set in macro-stdexten
exten => 2,1,Wait(1)                            ; wait 1 second
exten => 2,2,Playback(pls-hold-while-try)       ; please hold while we try that extension
exten => 2,3,Dial(${TRUNKLD}/1${FOLLOW},15,t)   ; call user via our LD trunk to our follow me number
exten => 2,4,Voicemail(u${EXT})
exten => h,1,Hangup                             ; if user hangs up
exten => t,1,Playback(goodbye)                  ; if we reach response timeout
exten => t,2,Hangup                             ; hangup the line

I call the macro like this:

exten => _XXX,1,Macro(stdexten,100,${CALLERID})