Asterisk cmd Read
Created by: oej,Last modification on Tue 06 of Jan, 2009 [16:43 UTC] by elizabethgreene
Synopsis
Read a variable in the form for DTMF tones as pressed by the callerDescription
As of Asterisk 1.0:Read(variable[|filename][|maxdigits][|option])
As of Asterisk 1.2:
Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])
As of Asterisk 1.4:
Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])
Reads a #-terminated string o
f digits a certain number of times from the user in to the given variable.
- variable: variable where the user's response will be stored.
- filename: file to play before reading digits.
- maxdigits: maximum acceptable number of digits. Stops reading after maxdigits have been entered (without requiring the user press the '#' key). Defaults to 0 - no limit - wait for the user press the '#' key. Any value below 0 means the same. Max accepted value is 255.
- option: may be 'skip' to return immediately if the line is not up, or 'noanswer' to read digits even if the line is not up.
- attempts: if greater than 1, that many attempts will be made in the event no data is entered.
- timeout: Timeout in seconds. If greater than 0, that value will override the default timeout.
Read should disconnect if the function fails or errors out.
; The Following Example uses Read and Say digits to read 3 digits from user, saying each one as user types.
Asterisk 1.2:
exten => s,1,Gotoif($[ "${LEN(${extensao})}" < "3"]?3:100)
exten => s,n,NoOp(executando - ${extensao} - )
exten => s,n,Read(digito||1)
exten => s,n,SayDigits(${digito})
exten => s,n,Set(extensao=${extensao}${digito})
exten => s,n,GoTo(s,1)
exten => s,100,GoTo(from-pstn,s,1)
exten => h,1,hangup()
Asterisk 1.4, 1.6:
exten => s,1,Gotoif($[ "${LEN(${extensao})}" < "3"]?3:100)
exten => s,n,NoOp(executando - ${extensao} - )
exten => s,n,Read(digito,,1)
exten => s,n,SayDigits(${digito})
exten => s,n,Set(extensao=${extensao}${digito})
exten => s,n,GoTo(s,1)
Note:
Pipe characters ( | ) have been changed to commas in Asterisk 1.6.
In Asterisk 1.4, either pipes OR commas will work. Using commas will ease future upgrades.
'#' is the End-Of-Input Key. It is NOT possible to accept '#' with Read()
Warning:
In Asterisk 1.4: the "filename" field does not accept concatenation (file1&file2&file...).
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Comments
333Multiple sound files issue
For a dialplan with static sound file names you can use - sox file1 file2 file3 file4 file1234 - to combine sound files 1,2,3&4 into file1234. it doesn't work when the sound filename is dynamically determined.
I use Read() way more frequently than Playback or Background.
3331.6 Change
333Cannot combine multiple sound files
333No Timeout