Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd WaitExten

Author image

Synopsis:

Waits for an extension to be entered; gives the caller the opportunity to push a new extension onto the stack

Description:

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

example in extensions.conf


exten => _X.,n,WaitExten(3)
 

This command is particularly interesting as it pushes the received extension back on to the stack and then restarts the current context. Consider the followig example, using AEL syntax:


context extensions {
        0 => &dial(main);
        10 => &dial(fax);
        // other "real" extensions 11..99 go here
        _[1-9] => { // this pattern needs to catch all incomplete extensions
                Set(Pre=${EXTEN});
                jump s@ext-wait;
        }
        s => {
                Set(Pre="");
                // optionally start playing a dial tone here
                jump s@ext-wait;
        }

}

context ext-wait {
        _X! => {
                // optionally stop any dial tone
                jump ${Pre}${EXTEN}@extensions;
        }
        s => {
                WaitExten();
        }
}

This pattern is particularly useful for direct dial in.

Notes

  • WaitExten does not work in a Macro!
  • The autofallthrough setting was 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 add 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 | Applications | Functions | Variables | Expressions | Asterisk FAQ


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.