login | register
Fri 10 of Oct, 2008 [22:57 UTC]

voip-info.org

History

Asterisk cmd WaitExten

Created by: oej,Last modification on Mon 15 of Sep, 2008 [00:13 UTC] by smurfix

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

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 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 | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments

Comments Filter
222

333consistency??

by robertm, Tuesday 05 of June, 2007 [23:32:01 UTC]
Just a comment about 'autofallthrough' & 'WaitExten'. In the notes above/below,
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.
222

333Workaround

by , Tuesday 12 of October, 2004 [03:33:57 UTC]
This example is a tone generator.
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)