Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asterisk GotoIf not actually going

Tags:

pbx

asterisk

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

like image 900
eran Avatar asked Dec 19 '25 09:12

eran


1 Answers

Found the problem, it was a redundant extra ']' at the end of the GotoIf statement.

should be:

same =>         n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion)

and not:

same =>         n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion])
like image 170
eran Avatar answered Dec 22 '25 16:12

eran