Macro to locate a user at up to two external numbers


The FindMe macro


;********************************************************************
[macro-findme]
;********************************************************************
;
; Dials the localextention then as many as
; 2 remote numbers to find a subscriber.
;
; ARG1 = local estension
; ARG2 = remote number 1 to try (cell?)
; ARG3 = remote number 2 to try (home?)
; ARG4 = time out value for each call
; ARG5 = Voicemail box if all else fails
; ARG6 = File announcing the name of the called party
;
;
; here we figure out what inbound circuit is being used
; and if available, what the caller ID is.
;
; ${RINGINGLINE} = Name of file announcing the ringing line
; ${CALLERIDNUM} = calling party caller ID number
;
exten => s,1,SetVar(LineAnnounce=${RINGINGLINE})
exten => s,2,SetVar(InCID=${CALLERIDNUM})
exten => s,3,SetGlobalVar(FOUNDME=foo)
;
exten => s,4,Background(custom/locating)
exten => s,5,Background(${ARG6})
exten => s,6,Wait(1)
exten => s,7,Background(custom/confirm-abort)
exten => s,8,DigitTimeout,1 ; give them 1 seconds between digits
exten => s,9,ResponseTimeout,10 ; give them 10 seconds to make a choice
;
exten => #,1,NoOp ; they chose not to proceed
exten => #,2,SetGlobalVar(FOUNDME=ABORT)
;
exten => *,1,NoOp ; they chose to go for it
exten => *,2,NoOp
exten => *,3,NoOp
;
; try localextension first
;
; first we need to make sure that we have something
; to dial that looks like it might be a valid
; localextension
;
exten => *,4,GoToIf($[${LEN(${ARG1})} = 2]?5:7)
exten => *,5,Macro(pana-announce,${ARG1},${ARG6},${LineAnnounce})
;
; if we still have control over the caller then the line
; was not picked up so we try a "Page All"
;
exten => *,6,Macro(pana-announce,${PAGEALL},${ARG6},${LineAnnounce})
;
; if we still have control over the caller then the line
; was not picked up so we try to transfer to first remote
; phone number.
;
;
exten => *,7,SetVar(NumToDial=${ARG2})
exten => *,8,NoOp
;
; if we dont get an answer on the first remote number we
; will loop back here with the second remote number ready
; to try again.
;
;
exten => *,9,NoOp
exten => *,10,SetGlobalVar(FOUNDME=foo)
;
; local calls in our area require 10 digits. A simple
; way to test for a valid number is to make sure the
; number to dial is at least 10 characters long.
;
exten => *,11,GoToIf($[${LEN(${NumToDial})} > 9]?14:12)
exten => *,12,NoOp(${NumToDial})
exten => *,13,Goto(s-NOANSWER,1)
;
exten => *,14,Background(transfer)
exten => *,15,Macro(dial-pstn-sip-iax,${NumToDial},${ARG4})
;
exten => *,16,Goto(s-${FOUNDME})
;
exten => s-ANSWER,1,NoOp
exten => s-ANSWER,2,NoOp
exten => s-ANSWER,3,NoOp
exten => s-ANSWER,4,SetGlobalVar(FOUNDME=bar)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,NoOp
exten => s-BUSY,4,Wait(1)
exten => s-BUSY,5,Goto(s-FINISHED,3)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,NoOp
exten => s-CANCEL,3,Wait(1)
exten => s-CANCEL,4,Goto(s-FINISHED,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,Wait(1)
exten => s-CHANUNAVAIL,4,Goto(s-FINISHED,1)
;
exten => s-NOANSWER,1,GoToIf($[${NumToDial} = ${ARG2}]?2:5)
exten => s-NOANSWER,2,SetVar(NumToDial=${ARG3})
exten => s-NOANSWER,3,GoToIf($[${LEN(${NumToDial})} < 9]?5:4)
exten => s-NOANSWER,4,Goto(s,9)
exten => s-NOANSWER,5,Goto(s-FINISHED,1)
;
exten => s-FINISHED,1,VoiceMail(u${ARG5})
exten => s-FINISHED,2,Goto(s-FINISHED,4)
exten => s-FINISHED,3,VoiceMail(b${ARG5})
exten => s-FINISHED,4,SetGlobalVar(FOUNDME=foo)
exten => s-FINISHED,5,Hangup
;
; here if we got something undocumented
; back from the DIAL command
;
exten => s-.,1,BackGround(something-terribly-wrong)
exten => s-.,2,GoTo(s-FINISHED,1)
;
exten => t,1,Goto(i,1) ; If they take too long, give up
;
exten => i,1,Background(custom/is-invalid) ; "That's not valid, try again"
exten => i,2,Wait(1)
exten => i,3,Goto(s,4)
;
;




The FindMe macro


;********************************************************************
[macro-findme]
;********************************************************************
;
; Dials the localextention then as many as
; 2 remote numbers to find a subscriber.
;
; ARG1 = local estension
; ARG2 = remote number 1 to try (cell?)
; ARG3 = remote number 2 to try (home?)
; ARG4 = time out value for each call
; ARG5 = Voicemail box if all else fails
; ARG6 = File announcing the name of the called party
;
;
; here we figure out what inbound circuit is being used
; and if available, what the caller ID is.
;
; ${RINGINGLINE} = Name of file announcing the ringing line
; ${CALLERIDNUM} = calling party caller ID number
;
exten => s,1,SetVar(LineAnnounce=${RINGINGLINE})
exten => s,2,SetVar(InCID=${CALLERIDNUM})
exten => s,3,SetGlobalVar(FOUNDME=foo)
;
exten => s,4,Background(custom/locating)
exten => s,5,Background(${ARG6})
exten => s,6,Wait(1)
exten => s,7,Background(custom/confirm-abort)
exten => s,8,DigitTimeout,1 ; give them 1 seconds between digits
exten => s,9,ResponseTimeout,10 ; give them 10 seconds to make a choice
;
exten => #,1,NoOp ; they chose not to proceed
exten => #,2,SetGlobalVar(FOUNDME=ABORT)
;
exten => *,1,NoOp ; they chose to go for it
exten => *,2,NoOp
exten => *,3,NoOp
;
; try localextension first
;
; first we need to make sure that we have something
; to dial that looks like it might be a valid
; localextension
;
exten => *,4,GoToIf($[${LEN(${ARG1})} = 2]?5:7)
exten => *,5,Macro(pana-announce,${ARG1},${ARG6},${LineAnnounce})
;
; if we still have control over the caller then the line
; was not picked up so we try a "Page All"
;
exten => *,6,Macro(pana-announce,${PAGEALL},${ARG6},${LineAnnounce})
;
; if we still have control over the caller then the line
; was not picked up so we try to transfer to first remote
; phone number.
;
;
exten => *,7,SetVar(NumToDial=${ARG2})
exten => *,8,NoOp
;
; if we dont get an answer on the first remote number we
; will loop back here with the second remote number ready
; to try again.
;
;
exten => *,9,NoOp
exten => *,10,SetGlobalVar(FOUNDME=foo)
;
; local calls in our area require 10 digits. A simple
; way to test for a valid number is to make sure the
; number to dial is at least 10 characters long.
;
exten => *,11,GoToIf($[${LEN(${NumToDial})} > 9]?14:12)
exten => *,12,NoOp(${NumToDial})
exten => *,13,Goto(s-NOANSWER,1)
;
exten => *,14,Background(transfer)
exten => *,15,Macro(dial-pstn-sip-iax,${NumToDial},${ARG4})
;
exten => *,16,Goto(s-${FOUNDME})
;
exten => s-ANSWER,1,NoOp
exten => s-ANSWER,2,NoOp
exten => s-ANSWER,3,NoOp
exten => s-ANSWER,4,SetGlobalVar(FOUNDME=bar)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,NoOp
exten => s-BUSY,4,Wait(1)
exten => s-BUSY,5,Goto(s-FINISHED,3)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,NoOp
exten => s-CANCEL,3,Wait(1)
exten => s-CANCEL,4,Goto(s-FINISHED,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,Wait(1)
exten => s-CHANUNAVAIL,4,Goto(s-FINISHED,1)
;
exten => s-NOANSWER,1,GoToIf($[${NumToDial} = ${ARG2}]?2:5)
exten => s-NOANSWER,2,SetVar(NumToDial=${ARG3})
exten => s-NOANSWER,3,GoToIf($[${LEN(${NumToDial})} < 9]?5:4)
exten => s-NOANSWER,4,Goto(s,9)
exten => s-NOANSWER,5,Goto(s-FINISHED,1)
;
exten => s-FINISHED,1,VoiceMail(u${ARG5})
exten => s-FINISHED,2,Goto(s-FINISHED,4)
exten => s-FINISHED,3,VoiceMail(b${ARG5})
exten => s-FINISHED,4,SetGlobalVar(FOUNDME=foo)
exten => s-FINISHED,5,Hangup
;
; here if we got something undocumented
; back from the DIAL command
;
exten => s-.,1,BackGround(something-terribly-wrong)
exten => s-.,2,GoTo(s-FINISHED,1)
;
exten => t,1,Goto(i,1) ; If they take too long, give up
;
exten => i,1,Background(custom/is-invalid) ; "That's not valid, try again"
exten => i,2,Wait(1)
exten => i,3,Goto(s,4)
;
;



Created by: ghendershot, Last modification: Mon 18 of Oct, 2004 (00:28 UTC)
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+