Asterisk "read" application customisation

here is my dial plan :slight_smile:
exten => s,1,NoOp(“The Context is :” ${CONTEXT} “and destination is”${EXTEN})
same => n,Playback(“hello-world”)
same => n,Read(digito,20)
exten => s,n,GotoIf($["${digito}" = “1”]?dial1)
exten => s,n,GotoIf($["${digito}" = “2”]?dial2)
exten => s,n,GotoIf($["${digito}" = “3”]?dial3)
exten => s,n(dial1),Dial(SIP/6472472369:6472472369@${digito},120,tr)
same => n,Hangup()
exten => s,n(dial2),Dial(SIP/6472472369:6472472369@${digito},120,tr)
same => n,Hangup()
exten => s,n(dial3),Dial(SIP/6472472369:6472472369@${digito},120,tr)
same => n,Hangup()

as we see above , if i put 1 then # it go to ip1
if i put 2 then # it go to ip 2

if i put 3 then # it go to ip3

but i want to change eh behaviour , is it possible if i put 1 it go directly and don’t wait me put # to ip1 ?

is it possible to do a mix, for example if they press 1 or 2 route right away without waiting for a # if they enter 3-9 it waits for #? and we will just mkae sure to never proviision a client ID that starts with 1 or 2?

For fixed length input, I believe you can specify the maximum number of digits.

For variable length input, you should use WaitExten, instead, as you can use the full dialplan extension number matching logic.

I don’t think that you can ‘do a mix’ using just one ‘Read’.

I would try something like this:
[ . . . ]

   same => n,Read(digito,hello-world,1,20)      ; Note the '1', this is the max digits accepted. You don't have to enter '#' after the digit.
   exten => s,n,GotoIf($["${digito}" = "1"]?dial1)
   exten => s,n,GotoIf($["${digito}" = "2"]?dial2)
   exten => s,n,GotoIf($["${digito}" = "3"]?dial3) 
  ; Option 1, direct dial (No # needed!)
   exten => s,n(dial1),Dial(SIP/6472472369:6472472369@${digito},120,tr)
   same => n,Hangup()
   ; Option 2, direct dial (No # needed!) 
   exten =>    s,n(dial2),Dial(SIP/6472472369:6472472369@${digito},120,tr)
   same => n,Hangup()
  ; Option 3, ask for '#'. 2nd Read
   exten =>  s,n(dial3),Read(var,1,20) 
   same => n,GotoIf($["${var}" = "#"]?dial3OK) ; If entered '#', we can Dial.
   same => s,n(dial3OK),Dial(SIP/6472472369:6472472369@${digito},120,tr)
    same => n,Hangup()

I’ve not tried this and there are several errors, but I hope you get the idea. Use the maxdigits parameter from Read application.


Use consecutive ‘Reads’ with maxdigits=1 to get that mix.

This is probably not the best solution, but you can make it work.