How I can play files while reading digit?

I call to AGI to got string with list of file name to play. I need to play the files, but give ability to user to stop it and send digit that Dialplan intends to deal with.

How to do that?

On the face of it it sounds you may be over compicating things, why dont you use Background or Read instead ?


certainly doesn’t sound like you need an AGI script to do what you are asking. That is pretty much the core functionality of the dialplan. :smile:

I just got finished setting this up for the first time myself. Use the Background application, which plays a file and waits for numerical input. I use it to play the menu options and then it just sits there.

One thing I did have to do was break the number out into its own context. We run an answering service, so we have dozens of numbers coming in and by default we put them all in to the same context.

When setting up a IVR, menu you have to put the number in its own context. This is because you have to define the behavior of what happens when a number is pressed such as 1 or 2. If you had all these menus in the same context, menu options would get all confused.

Here is some sample code:

exten => s,1,Answer
exten => s,2,Background(/var/lib/asterisk/sounds/menu)
exten => s,3,Wait(2)
exten => s,Hangup

exten => 1,1,Playback(hello) //If 1 is pressed, it plays hello
exten => 1,2,Hangup //Then it hangs up