Playing an announcement with Dial application

Hello. I’m trying to implement something like whispering on Asterisk.

Here is my situation.

  • During the call, our system calls operator by Dial application. Then the caller will talk with operator.
  • Right after operator picking up the call, we want to let our system play an announcement to the operator. (i.e. “This call is about …”)

I found that Dial application has an option “A(x)” which can do exactly what I want.


A(x):
    x - The file to play to the called party.  Play an announcement to the called party, where <x> is the prompt to be played

But, I want to improve the behavior because although this can play an audio to the operator, the caller can hear nothing during the play.
If the caller can hear some sound or music during audio is being played on the operator side, the experience would be much better.
How can I do it?

why don’t custom record the prompt and play it under A(x)

@ajayuzumaki12 Thanks for your suggestion, but I couldn’t understand what you mean.
I was able to play an announcement using A(x), but the issue I have is that the caller can hear nothing during the announcement. I want to play some sound so that caller can know he/she need to wait a little bit.

You can use G to split the legs, and bridge to merge them. Note that Bridge doesn’t indicate end of call to the dialplan interpreter when the other party hangs up, unlike the default behaviour of Dial.

@ogibayashi
You could use b() option to call a context that will play your announcement.
This option will do things before bridge caller and called legs, in other words, caller will keep hearing ringtone/hold music until b(context) completes their logic.

Hello. Sorry that it’s been a long time after your adviese.
Let me share what I ended up with.

After some trial and errors, ChanSpy worked as expected.


dialplan

[playsound3]
exten => whisper,1,Answer()
same => n,Verbose(Whisper)
same => n,ChanSpy(PJSIP/caller-channel,qw)
same => n,Hangup()

[playsound4]
exten => whisper,1,Answer()
same => n,Verbose(Whisper)
same => n,ChanSpy(PJSIP/called-channel,qw)
same => n,Hangup()

[default]
exten = 1235,1,Answer()
same = n,Dial(PJSIP/outgoing/sip:+8112345678@example.pstn.jp1.twilio.com:5060)
same = n,Wait(1)
same = n,Hangup()

then, after dialing, it was possible to connect to each whisper extension via AMI and execute Playback application. I played ringtone on caller channel while playing announcement on called channel.

Action: Originate
Channel: Local/whisper@playsound3
ActionID: 1235
Data: soundfile
Application: Playback

The G option seemed to work and much easier, but I wanted to execute Dial from AGI, and in that case caller was not tranferred to the priority.
(Maybe becuse AGI is not yet finished.)

I also tried the b option, but it seemd to be an option to execute Gosub in caller side.

Thank you for all your help.

These are dialplan, so they need to be written in extensions.conf.
To play sound, you need to originate a call using AMI. Audio file path is specified by “Data” field in the action with the relative path from /var/lib/asterisk/sounds in my setup.
In the below example, the sound path will be /var/lib/asterisk/sounds/soundfile.wav (or other file extension). You can refer to Playback application in the documentation for more detail.

Action: Originate
Channel: Local/whisper@playsound3
ActionID: 1235
Data: soundfile
Application: Playback