I am trying to configure a dialplan to GoTo a different context if the SIP header has a diversion number in it.
This is not working, as it is failing silently.
Here is my extensions.conf
file.
[from-external]
exten => _+<phone_number>,1,Noop(incoming call)
same => n,Answer()
same => n,Set(diversion=${SHELL(node ${scripts}/parsePhoneNumber.js ${SIP_HEADER(diversion)})})
same => n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion])
same => n(have_diversion),Noop(in existing diversion)
[MissingDiversion]
exten => 1004,1,Noop(in missing diversion)
same => n(missing_diversion_label),Noop(in missing diversion)
The log is:
== Using SIP RTP CoS mark 5
-- Executing [+16167270007@from-external:1] NoOp("SIP/incoming-trunk2-00000021", "incoming call") in new stack
-- Executing [+16167270007@from-external:2] Answer("SIP/incoming-trunk2-00000021", "") in new stack
-- Executing [+16167270007@from-external:3] Set("SIP/incoming-trunk2-00000021", "diversion=") in new stack
-- Executing [+16167270007@from-external:4] GotoIf("SIP/incoming-trunk2-00000021", "1?1004,1:have_diversion]") in new stack
-- Goto (from-external,1004,1)
So, it looks like the GOTO is working, but it is not reaching where I want it to reach. I do not see the log for in missing diversion
.
I have tried variants of the GotoIf
line, which also don't work:
same => n,GotoIf($["${diversion}" = ""]?
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1004]:have_diversion])
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1]:have_diversion])
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1004,1]:have_diversion])
Also, I just use a label withing the original context [from-external]
- the GotoIf
actually works. It is the jumping to a new context that fails.
I am running Asterisk 11.6