Read() function not allowing to read user input while playin


My Asterisk version: 11.9

When I am trying to store the dtmf input in a variable through read() function, it is not allowing me to store the entered digits during sound file playing. Once it completes the playing of welcome message, then only it is allowing me to store the input.

Below is my content:

(‘context’,’+11234567891’,‘5’,‘NoOp’,‘BEGIN EXECUTING AFTER WELCOME GREETING’);
(‘context’,’+11234567891’,‘9’,‘NoOp’,‘END EXECUTING AFTER MNCL GREETING’);

What I have to do to record the user DTMF input, while playing the audio file?

Any help would be appreciated. Thanks in advance.



Any update would be appreciated.

Thank you.

Background and Read use completely different ways of processing the digits. Background does an implied Goto, but Read makes them explicitly available. The documentation for Background tells you which application you should use in case the file completes before digits are entered.

Also, it is not sensible to continue playing a recording after the first digit, as the echo of the recording may jam the digit decoding.

What is your high level goal, rather than your tactic for achieving it?

Hello David,

Thank you for your reply. The problem is solved with Read() function by giving welcome message sound file along with other parameters. But, I am still confusing which one is better in IVR implementation? Either background() or Read()?

My high level goal is to catch the user input, while playing the sound file and do some validations. For this Read() is suitable. But, if there are no validations requires and simply just connects to the desired extension, background() is suitable. So, we no need to do any validations for simple IVR implementations.

What are your recommendations?

Thank you.

Reading whilst playing is unlikely to be the high level goal. There will be a higher level goal that makes that desirable.

The choice between Background and read depends on whether the application naturally leads to the number being processed as an “extension” with no further validation.

Thank you David.