Is it possible to read input digits in MusicOnHold?

Is it possible to read input digits like Read() in MusicOnHold()? I want to be able to read user input while listening to the hold music. Or do I have to use Read() with a music file in an infinite loop?

WaitExten(sec,m)

1 Like

To add on to that, use StartMusicOnHold (async), not MusicOnHold (blocking)

1 Like

You don’t specify anything else with WaitExten. The point of WaitExten is to wait for input; the (m) option specifies to play the default musiconhold channel (channel can be specified). Take a look at my inbound-IVR:

[inbound-ivr]
exten => s,1,Ringing()
same = n,Wait(5)
same = n,Answer()
same = n,Set(VOLUME(TX)=-2)
same = n,WaitExten(3600,m)
same = n,Hangup()

This gives people an hour to enter a number before it stops listening for digits. Then it hangs up. If I wanted to leave people on music, I’d add a normal line for musiconhold.

But if he puts a StartMusicOnHold() before WaitExten then it’ll just sit there and do nothing.

I’d suggest that you really want the music on hold to stop when a digit is detected, as echo could cause problems recognizing in-band tones.

Thank you
With Read(), I was able to get the input into a variable. However, with WaitExten() I don’t understand how I can access the entered value as a variable.

With WaitExten any input is treated as a dialed extension. You did not specify how you wanted the user input to be processed.

I’m sorry because I didn’t mention it. I need the input as a variable to use in AGI.

exten => _X.,1,Set(input=${EXTEN})

Could something like this work?

Looks worth a try.

Note that the current extension is already available in the AGI
environment variable agi_extension. (Automagically fed by Asterisk to your
AGI via STDIN.)

Exact naming and method may depend on the language and library you use.

1 Like

I haven’t gotten around to playing with AGI yet…it’s still on my list of stuff “to-do”. However I don’t think my method would be of any use since it’s for a system written entirely in dialplan.

But again…AGI is still a mystery to me so I might be surprised myself when I get around to trying it.

exten => _X!,1,Set(input=${EXTEN})

This solution worked but I also found that this also works:

exten => attendant_Queue_Indefinite_Announcement,n,StartMusicOnHold(${waitingclass})
exten => attendant_Queue_Indefinite_Announcement,n,Read(exitinput,,${max_inputlength},,1,3600)
exten => attendant_Queue_Indefinite_Announcement,n,StopMusicOnHold()

And I think that’s a cleaner way to do it. Thanks to everyone.

Or:

‘same’ and ‘whitespace’ are your friend :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.