Find next available least cost outbound channel


Dial out routines to find next best lowest cost channel


[macro-dial-pstn-sip-iax]
;
;
; This macro tries the PSTN circuit first, then
; fails over to our SIP provider and uses IAX
; as a last resort.
;
; As part of a least cost routing plan, this
; routine is best used for local calls.
;
; It should be noted that the PANASONIC hand sets
; have the option of manually selecting the
; line to be used for outbound dialing. Normally,
; this routine would only be of value to single
; line or IP phones as it is simpler to just select
; the outbound path at the PANASONIC hand set.
;
; Enter with these
; ARG1 = number to dial
; ARG2 = timeout value
; ARG3 = flag determines if hangup or return on no answer
; HR = hangup and return (default)
; RT = return without hangup (must set)
;
; Returns with FOUNDME = DIALSTATUS
;
exten => s,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s,2,Dial(${PSTN}/9w${ARG1},${ARG2})
exten => s,3,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,4,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?5:20)
;
exten => s,5,SetGlobalVar(FOUNDME=ANSWER)
exten => s,6,Dial(SIP/${ARG1}${SIPCO1},${ARG2})
exten => s,7,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,8,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?9:20)
;
exten => s,9,GotoIf($[${LEN(${ARG1})} = 10]?10:12)
exten => s,10,SetVar(NumToDial=1${ARG1})
exten => s,11,Goto(s,13)
exten => s,12,SetVar(NumToDial=${ARG1})
;
exten => s,13,SetGlobalVar(FOUNDME=ANSWER)
exten => s,14,Dial(${IAXCO1}/${NumToDial},${ARG2}) ; try VoicePulse server 1
exten => s,15,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,16,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?17:20)
;
exten => s,17,SetGlobalVar(FOUNDME=ANSWER)
exten => s,18,Dial(${IAXCO2}/${NumToDial},${ARG2}) ; try VoicePulse server 2
exten => s,19,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,20,Goto(s-${DIALSTATUS},1)
;
; returns here if busy on PSTN
;
exten => s,103,SetGlobalVar(FOUNDME=BUSY)
exten => s,104,Goto(s-BUSY,1)
;
; returns here if busy on SIP
;
exten => s,107,SetGlobalVar(FOUNDME=BUSY)
exten => s,108,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO1
;
exten => s,115,SetGlobalVar(FOUNDME=BUSY)
exten => s,116,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO2
;
exten => s,119,SetGlobalVar(FOUNDME=BUSY)
exten => s,120,Goto(s-BUSY,1)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,SetGlobalVar(FOUNDME=BUSY)
exten => s-BUSY,4,Goto(s-CLEANEXIT,1)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,SetGlobalVar(FOUNDME=CANCEL)
exten => s-CANCEL,3,Goto(s-CLEANEXIT,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,SetGlobalVar(FOUNDME=CHANUNAVAIL)
exten => s-CHANUNAVAIL,4,Goto(s-CLEANEXIT,1)
;
exten => s-NOANSWER,1,BackGround(nbdy-avail-to-take-call)
exten => s-NOANSWER,2,SetGlobalVar(FOUNDME=NOANSWER)
exten => s-NOANSWER,3,Goto(s-CLEANEXIT,1)
;
exten => s-ANSWER,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s-ANSWER,2,Goto(s-CLEANEXIT,3)
;
exten => _s-.,1,BackGround(something-Usr2bly-wrong)
exten => _s-.,2,SetGlobalVar(FOUNDME=ERROR)
exten => _s-.,3,Goto(s-CLEANEXIT,1)
;
exten => s-CLEANEXIT,1,GotoIf($[${ARG3} = RT]?3:2)
exten => s-CLEANEXIT,2,Hangup
exten => s-CLEANEXIT,3,NoOp
;
;
[macro-dial-iax-sip-pstn]
;
; This routine tries to connect using our IAX
; account with VoicePulse first. If for any
; reason, VoicePulse is unavailable, it fails
; over to our SIP account with BroadVoice. If
; BroadVoice fails also, it will use one of our
; analog lines with Verizon as a last resort.
;
; As part of a least cost routing plan, this
; routine is best used for long distance or
; international calls.
;
; It should be noted that the PANASONIC hand sets
; have the option of manually selecting the
; line to be used for outbound dialing. Normally,
; this routine would only be of value to single
; line or IP phones as it is simpler to just select
; the outbound path at the PANASONIC hand set.
;
;
; Enter with these
; ARG1 = number to dial
; ARG2 = timeout value
; ARG3 = flag determines if hangup or return on no answer
; HR = hangup and return (default)
; RT = return without hangup (must set)
;
; Returns with FOUNDME = DIALSTATUS
;
;
exten => s,1,GotoIf($[${LEN(${ARG1})} = 10]?2:4)
exten => s,2,SetVar(NumToDial=1${ARG1})
exten => s,3,Goto(s,5)
exten => s,4,SetVar(NumToDial=${ARG1})
;
exten => s,5,SetGlobalVar(FOUNDME=ANSWER)
exten => s,6,Dial(${IAXCO1}/${NumToDial},${ARG2}) ; try VoicePulse server 1
exten => s,7,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,8,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?9:20)
;
exten => s,9,SetGlobalVar(FOUNDME=ANSWER)
exten => s,10,Dial(${IAXCO2}/${NumToDial},${ARG2}) ; try VoicePulse server 2
exten => s,11,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,12,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?13:20)
;
exten => s,13,SetGlobalVar(FOUNDME=ANSWER)
exten => s,14,Dial(SIP/${ARG1}${SIPCO1},${ARG2})
exten => s,15,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,16,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?18:20)
;
exten => s,17,SetGlobalVar(FOUNDME=ANSWER)
exten => s,18,Dial(${PSTN}/9w${ARG1},${ARG2})
exten => s,19,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,20,Goto(s-${DIALSTATUS},1)
;
; returns here if busy on IAXCO1
;
exten => s,107,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO2
;
exten => s,111,Goto(s-BUSY,1)
;
; returns here if busy on SIPCO1
;
exten => s,115,Goto(s-BUSY,1)
;
; returns here if busy on PSTN
;
exten => s,119,Goto(s-BUSY,1)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,SetGlobalVar(FOUNDME=BUSY)
exten => s-BUSY,4,Goto(s-CLEANEXIT,1)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,SetGlobalVar(FOUNDME=CANCEL)
exten => s-CANCEL,3,Goto(s-CLEANEXIT,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,SetGlobalVar(FOUNDME=CHANUNAVAIL)
exten => s-CHANUNAVAIL,4,Goto(s-CLEANEXIT,1)
;
exten => s-NOANSWER,1,BackGround(nbdy-avail-to-take-call)
exten => s-NOANSWER,2,SetGlobalVar(FOUNDME=NOANSWER)
exten => s-NOANSWER,3,Goto(s-CLEANEXIT,1)
;
exten => s-ANSWER,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s-ANSWER,2,Goto(s-CLEANEXIT,3)
;
exten => s-.,1,BackGround(something-Usr2bly-wrong)
exten => s-.,2,SetGlobalVar(FOUNDME=ERROR)
exten => s-.,3,Goto(s-CLEANEXIT,1)
;
exten => s-CLEANEXIT,1,GotoIf($[${ARG3} = RT]?3:2)
exten => s-CLEANEXIT,2,Hangup
exten => s-CLEANEXIT,3,NoOp
;
;


Dial out routines to find next best lowest cost channel


[macro-dial-pstn-sip-iax]
;
;
; This macro tries the PSTN circuit first, then
; fails over to our SIP provider and uses IAX
; as a last resort.
;
; As part of a least cost routing plan, this
; routine is best used for local calls.
;
; It should be noted that the PANASONIC hand sets
; have the option of manually selecting the
; line to be used for outbound dialing. Normally,
; this routine would only be of value to single
; line or IP phones as it is simpler to just select
; the outbound path at the PANASONIC hand set.
;
; Enter with these
; ARG1 = number to dial
; ARG2 = timeout value
; ARG3 = flag determines if hangup or return on no answer
; HR = hangup and return (default)
; RT = return without hangup (must set)
;
; Returns with FOUNDME = DIALSTATUS
;
exten => s,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s,2,Dial(${PSTN}/9w${ARG1},${ARG2})
exten => s,3,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,4,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?5:20)
;
exten => s,5,SetGlobalVar(FOUNDME=ANSWER)
exten => s,6,Dial(SIP/${ARG1}${SIPCO1},${ARG2})
exten => s,7,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,8,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?9:20)
;
exten => s,9,GotoIf($[${LEN(${ARG1})} = 10]?10:12)
exten => s,10,SetVar(NumToDial=1${ARG1})
exten => s,11,Goto(s,13)
exten => s,12,SetVar(NumToDial=${ARG1})
;
exten => s,13,SetGlobalVar(FOUNDME=ANSWER)
exten => s,14,Dial(${IAXCO1}/${NumToDial},${ARG2}) ; try VoicePulse server 1
exten => s,15,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,16,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?17:20)
;
exten => s,17,SetGlobalVar(FOUNDME=ANSWER)
exten => s,18,Dial(${IAXCO2}/${NumToDial},${ARG2}) ; try VoicePulse server 2
exten => s,19,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,20,Goto(s-${DIALSTATUS},1)
;
; returns here if busy on PSTN
;
exten => s,103,SetGlobalVar(FOUNDME=BUSY)
exten => s,104,Goto(s-BUSY,1)
;
; returns here if busy on SIP
;
exten => s,107,SetGlobalVar(FOUNDME=BUSY)
exten => s,108,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO1
;
exten => s,115,SetGlobalVar(FOUNDME=BUSY)
exten => s,116,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO2
;
exten => s,119,SetGlobalVar(FOUNDME=BUSY)
exten => s,120,Goto(s-BUSY,1)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,SetGlobalVar(FOUNDME=BUSY)
exten => s-BUSY,4,Goto(s-CLEANEXIT,1)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,SetGlobalVar(FOUNDME=CANCEL)
exten => s-CANCEL,3,Goto(s-CLEANEXIT,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,SetGlobalVar(FOUNDME=CHANUNAVAIL)
exten => s-CHANUNAVAIL,4,Goto(s-CLEANEXIT,1)
;
exten => s-NOANSWER,1,BackGround(nbdy-avail-to-take-call)
exten => s-NOANSWER,2,SetGlobalVar(FOUNDME=NOANSWER)
exten => s-NOANSWER,3,Goto(s-CLEANEXIT,1)
;
exten => s-ANSWER,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s-ANSWER,2,Goto(s-CLEANEXIT,3)
;
exten => _s-.,1,BackGround(something-Usr2bly-wrong)
exten => _s-.,2,SetGlobalVar(FOUNDME=ERROR)
exten => _s-.,3,Goto(s-CLEANEXIT,1)
;
exten => s-CLEANEXIT,1,GotoIf($[${ARG3} = RT]?3:2)
exten => s-CLEANEXIT,2,Hangup
exten => s-CLEANEXIT,3,NoOp
;
;
[macro-dial-iax-sip-pstn]
;
; This routine tries to connect using our IAX
; account with VoicePulse first. If for any
; reason, VoicePulse is unavailable, it fails
; over to our SIP account with BroadVoice. If
; BroadVoice fails also, it will use one of our
; analog lines with Verizon as a last resort.
;
; As part of a least cost routing plan, this
; routine is best used for long distance or
; international calls.
;
; It should be noted that the PANASONIC hand sets
; have the option of manually selecting the
; line to be used for outbound dialing. Normally,
; this routine would only be of value to single
; line or IP phones as it is simpler to just select
; the outbound path at the PANASONIC hand set.
;
;
; Enter with these
; ARG1 = number to dial
; ARG2 = timeout value
; ARG3 = flag determines if hangup or return on no answer
; HR = hangup and return (default)
; RT = return without hangup (must set)
;
; Returns with FOUNDME = DIALSTATUS
;
;
exten => s,1,GotoIf($[${LEN(${ARG1})} = 10]?2:4)
exten => s,2,SetVar(NumToDial=1${ARG1})
exten => s,3,Goto(s,5)
exten => s,4,SetVar(NumToDial=${ARG1})
;
exten => s,5,SetGlobalVar(FOUNDME=ANSWER)
exten => s,6,Dial(${IAXCO1}/${NumToDial},${ARG2}) ; try VoicePulse server 1
exten => s,7,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,8,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?9:20)
;
exten => s,9,SetGlobalVar(FOUNDME=ANSWER)
exten => s,10,Dial(${IAXCO2}/${NumToDial},${ARG2}) ; try VoicePulse server 2
exten => s,11,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,12,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?13:20)
;
exten => s,13,SetGlobalVar(FOUNDME=ANSWER)
exten => s,14,Dial(SIP/${ARG1}${SIPCO1},${ARG2})
exten => s,15,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,16,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?18:20)
;
exten => s,17,SetGlobalVar(FOUNDME=ANSWER)
exten => s,18,Dial(${PSTN}/9w${ARG1},${ARG2})
exten => s,19,SetGlobalVar(FOUNDME=${DIALSTATUS})
exten => s,20,Goto(s-${DIALSTATUS},1)
;
; returns here if busy on IAXCO1
;
exten => s,107,Goto(s-BUSY,1)
;
; returns here if busy on IAXCO2
;
exten => s,111,Goto(s-BUSY,1)
;
; returns here if busy on SIPCO1
;
exten => s,115,Goto(s-BUSY,1)
;
; returns here if busy on PSTN
;
exten => s,119,Goto(s-BUSY,1)
;
exten => s-BUSY,1,BackGround(the-party-you-are-calling)
exten => s-BUSY,2,BackGround(is-curntly-busy)
exten => s-BUSY,3,SetGlobalVar(FOUNDME=BUSY)
exten => s-BUSY,4,Goto(s-CLEANEXIT,1)
;
exten => s-CANCEL,1,BackGround(canceled)
exten => s-CANCEL,2,SetGlobalVar(FOUNDME=CANCEL)
exten => s-CANCEL,3,Goto(s-CLEANEXIT,1)
;
exten => s-CHANUNAVAIL,1,BackGround(channel)
exten => s-CHANUNAVAIL,2,BackGround(is-curntly-unavail)
exten => s-CHANUNAVAIL,3,SetGlobalVar(FOUNDME=CHANUNAVAIL)
exten => s-CHANUNAVAIL,4,Goto(s-CLEANEXIT,1)
;
exten => s-NOANSWER,1,BackGround(nbdy-avail-to-take-call)
exten => s-NOANSWER,2,SetGlobalVar(FOUNDME=NOANSWER)
exten => s-NOANSWER,3,Goto(s-CLEANEXIT,1)
;
exten => s-ANSWER,1,SetGlobalVar(FOUNDME=ANSWER)
exten => s-ANSWER,2,Goto(s-CLEANEXIT,3)
;
exten => s-.,1,BackGround(something-Usr2bly-wrong)
exten => s-.,2,SetGlobalVar(FOUNDME=ERROR)
exten => s-.,3,Goto(s-CLEANEXIT,1)
;
exten => s-CLEANEXIT,1,GotoIf($[${ARG3} = RT]?3:2)
exten => s-CLEANEXIT,2,Hangup
exten => s-CLEANEXIT,3,NoOp
;
;

Created by: ghendershot, Last modification: Wed 22 of Dec, 2004 (18:17 UTC) by netplex
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+