1
votes

In asterisk dialplan why it is so when dtmf input is two or more digits and if a digit is pressed when the prompt is being played it goes into i extension(invalid extension) as in case of single digit dtmf input if digit is pressed as the prompt is being played it moves into the right extension? thanks

3

3 Answers

4
votes

Here's another example where a user must enter a 4 digit PIN to continue in the dialplan:

[Login]
exten = s,1,Playback(/var/lib/asterisk/sounds/custom/login)
exten = s,n,Set(rightPIN=1234)
exten = s,n,Read(inPIN,/var/lib/asterisk/sounds/custom/enterPIN,4)
exten = s,n,GotoIf($["${inPIN}" = "${rightPIN}"]?pin-accepted,1)

; Didn't go to pin-accepted, so play badPIN and hangup
exten = s,n,Playback(/var/lib/asterisk/sounds/custom/badPINgoodbye)
exten = s,n,Hangup()

; correct pin, play something
exten = pin-accepted,1,Playback(/var/lib/asterisk/sounds/custom/something)
...

The third parameter of the Read() application is how many digits to wait for. For more information on Read, see Asterisk Wiki: Read

Edit: There's also a dialplan app called Authenticate that does this quite well.

0
votes

This will depend on how your diaplan is configured, but it sounds like you are using the background() application. Background() will listen for DTMF and then route to an extension in the current context on the 1st unambiguous match.

For example if you have 1, 2 and 100 in the context then pressing 2 will route directly to 2 (because it's unambiguous.) Pressing 1 will wait for a timeout because background() doesn't know if you are going to 1 or 100. After the timeout it will route to 1. Pressing 3 will go to the i special extension because there's is not extensions in the current context that start with 3.

If the desired behavior is to route from your IVR context to one of your internal phones then you need to include the phones context inside the IVR context:

[phones]
exten => 100,1,Dial(SIP/phone1)
exten => 101,1,Dial(SIP/phone2)
...

[IVR]
exten => s,1,Background(message)

exten => 1,1,Queue(Sales)
exten => 2,1,Queue(Support)
exten => i,1,Playback(pbx-invalid)

include => phones

More info in official documentation: https://wiki.asterisk.org/wiki/display/AST/Application_BackGround

0
votes

I recomend you start from reading this:

http://astbook.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/asterisk-CHP-5-SECT-1.html

or ORelly's book "Asterisk the future of telephony".