IVR don't work correct


Why in my script don’t work the [color=#00BF00]i[/color] number? I calling on my Asterisk and I hear the IVR_1. Then Astrisk waiting insert add numbers. If I insert correct add number all ok else (if I insert any number from 5-10 and more numerals) Asterisk just wait 10 sec and sending call to phones 17 or 20. Why?

exten => s,1,Answer 
exten => s,n,Background(/ast_sound/ivr/IVR_1) 
exten => s,n,WaitExten(10) 
exten => s,n,Hangup()

exten => _XXX,1,Dial(SIP/phone${EXTEN},10,tTg) 
exten => _XXX,n,Dial(SIP/phone17,15,tTg) 
exten => _XXX,n,Dial(SIP/phone20,15,tTg) 
exten => _XXX,n,Playback(/ast_sound/ivr/IVR_2) 
exten => _XXX,n,Playback(/ast_sound/ivr/IVR_6) 
exten => _XXX,n,Voicemail(8@default,s) 
exten => _XXX,n,Hangup() 

exten => i,1,Answer() 
exten => i,n,Playback(/ast_sound/ivr/IVR_3) 
exten => i,n,Playback(/ast_sound/ivr/IVR_4) 
exten => i,n,Dial(SIP/phone17,15) 
exten => i,n,Dial(SIP/phone20,15,tTg) 
exten => i,n,Playback(/ast_sound/ivr/IVR_2) 
exten => i,n,Playback(/ast_sound/ivr/IVR_6) 
exten => i,n,Voicemail(8@default,s) 
exten => i,n,Hangup() 

exten => t,1,Playback(/ast_sound/ivr/IVR_4) 
exten => t,n,Dial(SIP/phone17,15) 
exten => t,n,Dial(SIP/phone20,15,tTg) 
exten => t,n,Playback(/ast_sound/ivr/IVR_2) 
exten => t,n,Playback(/ast_sound/ivr/IVR_6) 
exten => t,n,Voicemail(8@default,s) 
exten => t,n,Hangup() 

Because your extension pattern ‘_XXX’ is 3 digits long, when the user enters only 1 or 2 digits, Asterisk must wait to see if any more digits are going to be entered. It waits until the timeout and then runs the timeout ‘t’ extension and not the invalid extension ‘i’ because it timed out.

If instead you had an extension pattern of _1XX, then if the user started entering by entering any number other than 1, it would immediately go to the invalid extension because then is no possible match for digits 2-9.

I see. But if user enters 3 or more digist, Asterisk nevertheless don’t goto “i” extension/

Since your are using WaitExten() Asterisk is attempting to match digits as the caller enters them, when it sees 3 digits, it has a valid match and jumps to that extension. If you want the user to be able to enter any number of digits without Asterisk attempting to match them, then you want to use the Read() application instead.