# Asterisk "read" application customisation

**URL:** <https://community.asterisk.org/t/asterisk-read-application-customisation/70844>\
**Category:** Asterisk Support\
**Created:** [May 25, 2017, 6:47am UTC](https://community.asterisk.org/t/asterisk-read-application-customisation/70844 "2017-05-25T06:47:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr.x](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/dr.x/32/2052_2.png) [@dr.x](https://community.asterisk.org/u/dr.x)\
**Post date:** [May 25, 2017, 6:47am UTC](https://community.asterisk.org/t/asterisk-read-application-customisation/70844/1 "2017-05-25T06:47:51Z")

</div>

here is my dial plan 🙂  
[hola]  
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@10.101.0.6/${digito},120,tr)  
same =\> n,Hangup()  
exten =\> s,n(dial2),Dial(SIP/6472472369:6472472369@10.150.0.235/${digito},120,tr)  
same =\> n,Hangup()  
exten =\> s,n(dial3),Dial(SIP/6472472369:6472472369@10.25.0.100/${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?

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 25, 2017, 7:44am UTC](https://community.asterisk.org/t/asterisk-read-application-customisation/70844/2 "2017-05-25T07:44:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HectorRoyo92](https://avatars.discourse-cdn.com/v4/letter/h/9e8a1a/32.png) [@HectorRoyo92](https://community.asterisk.org/u/HectorRoyo92)\
**Post date:** [May 25, 2017, 7:47am UTC](https://community.asterisk.org/t/asterisk-read-application-customisation/70844/3 "2017-05-25T07:47:00Z")

</div>

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@10.101.0.6/${digito},120,tr)
   same => n,Hangup()
   ; Option 2, direct dial (No # needed!) 
   exten => s,n(dial2),Dial(SIP/6472472369:6472472369@10.150.0.235/${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@10.25.0.100/${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.

```
Read(variable[,filename[&filename2[&...]][,maxdigits[,options[,attempts[,timeout]]]]])

```

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

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