Synopsis:
Waits for an extension to be entered; gives the caller the opportunity to push a new extension onto the stackDescription:
WaitExten(seconds)WaitExten([seconds][|options])
Waits for the user to enter a new extension for the specified number of seconds, then returns 0. Seconds can be passed with fractions of a second. (eg: 1.5 = 1.5 seconds).
Options:
m[(x)] - Provide music on hold to the caller while waiting for an extension.Optionally, specify the class for music on hold within parenthesis.
Example
This command is particularly interesting as it pushes the received extension back on to the stack and then restarts the current context. Consider:
[waitexten_example]
exten => s,1,NoOp(${TIMESTAMP} waitexten_example begins)
exten => s,2,DigitTimeout,1 ; Initially a 1 second pause during dialing will be treated as 'finished dialing'
exten => s,3,ResponseTimeout,10 ; 10 seconds without any digits at all is a problem...
exten => _X,1,NoOp( only got one digit. It was ${EXTEN})
exten => _X,2,SetVar(Predigits=${EXTEN}) ; Put that digit aside for use later...
exten => _X,3,Goto(s-gathermoredigits,1)
exten => s-gathermoredigits,1,NoOp( users have slow fingers - lets increase the DigitTimeout and try again)
exten => s-gathermoredigits,2,DigitTimeout,5 ; Increase the 'finished dialing' timeout to 5 seconds
exten => s-gathermoredigits,3,WaitExten(8) ; and give the caller 8 seconds overall to do their thing
exten => _X.,1,NoOp(${TIMESTAMP} ok, now we're going to dial ${Predigits}${EXTEN})
exten => _X.,2,Dial(facility/${Predigits}${EXTEN})
With a little work we could give various DigitTimeouts to different uses of inband DTMF, such as _9 for PSTN targets.
I was not able to get the above example to work properly (it seems to be missing a Background or a WaitExten() command??)
I am not really sure why you would want to do this with WaitExten() (Unless you have a specific application for waiting for *optional*
digits to be pressed (IVR menus etc.) If you just want to prompt the user to enter some digit(s) (i.e, an extension number) it would be easier to use the Read() command for this situation.
Notes
- The autofallthrough setting introduced in Asterisk 1.2 now defaults to 'yes' in Asterisk 1.4; if your dialplan relies on the ability to 'run off the end' of an extension and wait for a new extension without using WaitExten() to accomplish that, you will need set autofallthrough to 'no' in your extensions.conf file. If you want to set autofallthrough to 'no', you must go through your dialplan and added WaitExten() at every place where execute would run off the end of an extension and wait for another one to be dialed.
- An examination of the source code seems to suggest that TIMEOUT(response) and TIMEOUT(digit) do not have any effect on WaitExten.
A user experience
"autofallthrough=yes" causes the ResponseTimeout() to be ignored (as far as I can tell). After running out of extensions in a context, instead of waiting the amount of time specified in ResponseTimeout() and proceeding to t, the hangup extension (h) is reached. So: In order to obtain the behavior described above, make sure that autofallthrough is not set.Compared to the old Asterisk 1.0 way...
... there is a new option in Asterisk 1.2 called "autofallthrough" in extensions.conf that is set to yes. Asterisk 1.0 (and earlier) behavior was to wait for an extension to be dialed after there were no more extensions to execute. "autofallthrough" changes this behavior so that the call will immediately be terminated with BUSY, CONGESTION, or HANGUP based on Asterisk's best guess. If you are writing an extension for IVR, you must use the WaitExten application if "autofallthrough" is set to yes.See also:
Asterisk | Asterisk - documentation of application commands
Asterisk cmd DISA
Page Changes
consistency??
it says
"If you want to set autofallthrough to 'no', you must go through your dialplan and
added WaitExten() at every place where execute would run off the end of an extension
and wait for another one to be dialed."
but also in 'Compared to the old Asterisk 1.0 way...' it says
"If you are writing an extension for IVR, you must use the WaitExten application
if "autofallthrough" is set to yes."
Surely one of these statements is incorrect.
regards
rob.
Workaround
It can generate up to 4 simultaneous tones from 0 to 9999
dtmfgen_ctx
exten => s,1,Answer()
exten => s,2,SetVar(tone-no=1)
exten => *,1,Playtones(${tone1}+${tone2}+${tone3}+${tone4})
exten => #,1,SetVar(tone-no=$${tone-no} + 1)
exten => #,2,GotoIf($${tone-no} = 5?dtmfgen_ctx,*,1)
exten => i,1,SetVar(tone${tone-no}=${tone${tone-no}}${INVALID_EXTEN})
exten => i,2,NoOp(${LEN(${tone${tone-no}})})
exten => i,3,GotoIf($${LEN(${tone${tone-no}})} = 4?dtmfgen_ctx,#,1)