Search code examples
asterisktelephony

Dialplan execution order


I have the following context in my asterisk dialplan.

[start-call]
exten => _X.,1,AGI(agi://localhost:4000)
exten => _X.,n,GotoIf($["${AGISTATUS}" = "FAILURE"]?redirect)
exten => _X.,1000(redirect),Hangup(31)    
exten => 900,n,Goto(start-call,${EXTEN},1)
exten => h,n,Hangup

I have an AGI app which connects the call and collects DTMF inputs, and set that number as the extension using the SET EXTENSION agi command (line 1). I set the AGISTATUS to FAILURE only when there is no DTMF input. If there is no input, I timeout, and hangup (line 3). But if 900 is entered I go back to start-call context and do some magic in the AGI application (line 4).

The problem is that, right now even if I enter 900 the call just gets hung up. And not from line 3 but the last line. So its skipping line 4 somehow. If I move the 900 extension (line 4) before the one labelled redirect (line 3), it works.

I thought asterisk increments the 'n' priority automatically, and would expect this to work in the order listed above. Am I wrong here?


Solution

  • Dialplan must be consecutive. Ext 1000 is never hit - hence asterisk falls through to the h exten.