3

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

eran
  • 14,496
  • 34
  • 98
  • 144
  • Logs you show is usless, you have see what happens afte that. Nothing to do with gotoIF, check your dialplan where you send it. – arheops Mar 04 '18 at 17:22
  • That is the end of the log. That's exactly my problem. – eran Mar 05 '18 at 05:40

2 Answers2

2

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])
eran
  • 14,496
  • 34
  • 98
  • 144
  • That's a silly mistake. My main issue is, how the hell do I get usefull logs to help me catch such a mistake... – eran Mar 05 '18 at 08:51
0

You should include your new context into from-external OR do goto as MissingDiversion,1004,1

arheops
  • 15,544
  • 1
  • 21
  • 27
  • How do i include a new context under an existing one? – eran Mar 05 '18 at 05:40
  • Before try configure asterisk it is highly recommended read book like ORelly's Asterisk the Future of Telephony. Will be no such questions. You can find how use dialplan in any beginners book. You just wasting time triing do staff without understand basic of dialplan. – arheops Mar 05 '18 at 09:41