What is wrong?

Hi, i´m a beginner in asterisk and I created a dialplan/rule to use 2 differents trunks depending if it´s an internal call (start with 2) or not. I´m getting from asterisk log that it can´t understand “n” and, when I remove it, the fails msg stop too, but then I can´t use asterisk how I need, my calls didn´t work. I know that something is not right, but I already tried in a lot of different ways but I didn´t find the correct way to do that. Can you help me please? If possible, can you explain me why it´s not working to I be able fix it by myself in future cases?

[disc-from-trunk-SkypeTroncoAuto]
exten => _[#0-9].,n,GotoIf($["${EXTEN:0:1}" != “2”]?7)
exten => _[
#0-9].,1,Set(GLOBAL(TRUNK)=SkypeTroncoAuto)
exten => _[#0-9].,2,Set(FROM_DID=${EXTEN}|)
exten => _[
#0-9].,3,NoOp(${ACCOUNTCODE})
exten => _[#0-9].,4,NoOp(${EXTEN})
exten => _[
#0-9].,5,Set(Description=“Exten = ${EXTEN} / Channel = ${CHANNEL} / CalledID = ${CALLERID(all)}”)
exten => [#0-9].,6,Goto(disc-from-internal-additional,${EXTEN},1)
exten => _[
#0-9].,7,Set(GLOBAL(TRUNK)=SkypeTronco)
exten => [#0-9].,8,Set(FROM_DID=${EXTEN})
exten => _[
#0-9].,9,Goto(disc-inrt-SkypeIn,
[*#0-9].,1)
exten => s,1,Set(GLOBAL(TRUNK)=SkypeTronco)
exten => s,2,Set(FROM_DID=s)
exten => s,3,Goto(disc-inrt-SkypeIn,
[*#0-9].,1)

The error msg: ERROR : safe_strtoint: caught bad lex cast exception in strtoint, [] is not convertible

Thanks in advance.
Magno
magno_jr@terra.com.br

Hello Magno,

n - mean next (priority) but have no sense to put this line as your first line.

A valid dialplan have to start with priority 1 and continue with 2,3,… or to have all next lines with “n” to the priority. In this last case you have to use a method to specify how to “jump” to a specific priority, like n(step1) and use step1 as your destination in Goto like functions.

Your dialplan should look like:

[disc-from-trunk-SkypeTroncoAuto] exten => _[*#0-9].,1,GotoIf($["${EXTEN:0:1}" != "2"]?8) exten => _[*#0-9].,2,Set(GLOBAL(TRUNK)=SkypeTroncoAuto) exten => _[*#0-9].,3,Set(FROM_DID=${EXTEN}|) ...

I advice to check “Asterisk The Future of Telephony” doc in order to familiarize with Asterisk dialplan.

HTH,
Ioan.