Update, here's what works for me with Asterisk 17 / FreePBX 15 and PJSIP. I removed that second Set command and it allowed the process to proceed. I also had to adjust the Dial string to use PJSIP. The one part highlighted below is the hardcoded name of my trunk, which I can't figure out how to obtain via variable. If any of you have input there I'm open to it.
I'm also seeing a warning "Macro() is deprecated and will be removed from a future version of Asterisk", with a suggestion to rewrite with Gosub instead. I have not yet tackled that piece.
Oh, and that sip5060.net URI I was using to test with originally is not working. The nerdvittles URI however is working, so if you are testing this in 2021 try
[email protected] for test calls.
;# // BEGIN SIP URI Mod1
; Portions of the following code are Copyright (c) 2019, Ward Mundy & Associates LLC
; Licensed for use pursuant to GPL2:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
[enable-sipuri-dialing]
exten => _.,1,Set(MyDomain=${CUT(SIPCALLID,@,2)})
exten => _.,n,NoOp(SIPDOMAIN: ${SIPDOMAIN})
exten => _.,n,GotoIf($["foo${MyDomain}" != "foo"]?FoundDomain)
exten => _.,n,Set(MyDomain=${DB(MyDomain/FQDN)})
exten => _.,n(FoundDomain),GotoIf($["${MyDomain}" = "${SIPDOMAIN}"]?OutAllRoutes)
exten => _.,n,Macro(uridial,${EXTEN}@${SIPDOMAIN})
exten => _.,n(OutAllRoutes),Set(DSTRING=${LEN(${EXTEN})})
exten => _.,n,ExecIf($[${DSTRING} > 5]?Goto(outbound-allroutes,${EXTEN},1)
exten => _.,n,ExecIf($["${EXTEN}" = "911"]?Goto(outbound-allroutes,${EXTEN},1)
exten => _.,n,ExecIf($["${EXTEN}" = "933"]?Goto(outbound-allroutes,${EXTEN},1)
exten => _.,n,Dial(local/${EXTEN}@from-internal-additional)
;# // END SIP URI Mod1
;# // BEGIN SIP URI Mod2
; Portions of the following code are Copyright (c) 2019, Ward Mundy & Associates LLC
; Licensed for use pursuant to GPL2:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
[macro-uridial]
exten => s,1,Set(dialuri=${CUT(ARG1,\;,1)})
exten => s,n,NoOp(DIALURI: ${dialuri})
exten => s,n,Set(CALLERID(number)=${DB(${CALLERID(number)}/user_sipname)})
exten => s,n,ExecIf($["${CALLERID(number)}" = ""]?Set(CALLERID(number)=Anonymous))
exten => s,n,NoOp(Called SIP URI: ${dialuri})
exten => s,n,NoOp(Calling From : ${CALLERID(all)} ?^?^?)
exten => s,n,Dial(PJSIP/
VoipMS_SIP/sip:${dialuri},60,tr)
exten => s,n,Congestion()
exten => s,n,Return
;# // END SIP URI Mod2