I’ve setup the outbound routes and they work correctly, but what I’d like to do is on congestion to try an alternate outbound carrier. So I’ve tried using custom extensions and customer destinations.
Within extensions_customer.conf, I’ve added this script:
[Mex52X-Sprint/ATT-Failover]
exten => _901152X.,1,Answer
exten => _901152X.,n,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _901152X.,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))
exten => _901152X.,n,ExecIf($[ “${CALLEE_ACCOUNCODE}” != “” ] ?Set(CDR(accountcode)=${CALLEE_ACCOUNCODE}))
exten => _901152X.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _901152X.,n,Macro(dialout-trunk,3,10#52${EXTEN:5},on)
exten => _901152X.,n,Macro(dialout-trunk,4,40#52${EXTEN:5},off)
exten => _901152X.,n,Set(CALLERID(all)=${ROUTE_CIDSAVE})
exten => _901152X.,n,Set(_KEEPCID=TRUE)
exten => _901152X.,n,Hangup()
exten => _901152X.,n,Wait(1)
Results:
[2019-03-01 17:49:36] VERBOSE[32568][C-00000024] pbx.c: Executing [[email protected]:25] Dial(“PJSIP/222-00000035”, “PJSIP/10#5252X.@mysip,300,Tb(func-apply-sipheaders^s^1,(3))”) in new stack
When the congestion occurs, I can see the macro is being called properly, but it’s not pulling the DIAL_NUMBER from the initial outbound route. I believe it’s due to this line:
exten => _901152X.,n,Macro(dialout-trunk,3,10#52${EXTEN:5},on)
The EXTEN:5 isn’t proper I think? How do I pull the DIAL_NUMBER from the first outbound route?
Also if someone can explain how EXTEN is used and how that number following EXTEN is selected it would really clarify a few things.