IVR-how to use # to make Asterisk stop waiting for digits

I have a simple IVR using the background application.
On the IVR of my old PBX users were used to be able to press # after they had entered the digits and the application would stop waiting for digits and continue immediately.
Is there a way to replicate this behaviour on Asterisk?

So on background application, when user presses #, Asterisk should stop waiting for digits and continue immediately. Possible?

exten => s,1,Noop(Waiting for Paging digits)
 same => n,answer()
 same => n,Background(custom/pager_greeting)
 same => n,WaitExten()

exten => _Z.,1,playback(custom/page-is-being-sent)
exten => _Z.,n,system(echo "NEW PAGE, please call ${EXTEN}." | mailx -r "asterisk@abcd.org" email@email.org)

Are you aware of β€œ!”, which will allow Asterisk to stop reading once it has a match?

Otherwise, you will need patterns for every valid length, ending in '#; and then strip out the β€˜#’.

1 Like

Is there a way to immediately match any digit string of unknown length ending with a specific character?

Something like exten =>_Z.#! (I know this doesn’t work, but just trying to illustrate what I want to accomplish)

There is no way of doing that.

1 Like

Note that Read does terminate on #, but you cannot provide patterns to let it terminate early without the #.