Asterisk, How can i play an audio file
Asked Answered
D

3

6

Here is the dial plan

[testInComingCalls]

exten => s,1,Answer

exten => 30953025,1,Dial(SIP/20000,20)

I would like to play an audio file as soon as somebody answered the call..

Please give me some idea how to call a php file, send the input and based on the output forward the call.

Dunkin answered 31/1, 2014 at 5:53 Comment(0)
F
6

Since most of the Dial options act on the called party, not the caller, you have to get a little creative. It is a little odd to do such things to the caller as opposed to the called party, but hey, it's Asterisk: there's usually a way to do whatever you want.

One approach would be to use the lesser known (and somewhat strange) G option. Quoting from the documentation:

If the call is answered, transfer the calling party to the specified priority and the called party to the specified priority plus one.

  • context
  • exten
  • priority

Basically, the G option takes the caller/called channel and - instead of bridging them together - bounces both of them out to the dialplan. You can then get a little creative to perform your Playback operation before putting them in a Bridge together. The following Dialplan should work (caveat: I haven't tested this and I'm sitting on a laptop on a couch, but this should get you close):

[default]

exten => 1000,1,NoOp()
 same => n,Dial(SIP/alice,,G(default^bridge_and_play^1))
 same => n,Hangup()

exten => bridge_and_play,1,Goto(jump_caller,1)
 same => n,Goto(jump_called,1)
 same => n,Hangup()

exten => jump_caller,1,NoOp()
 same => n,Answer()
 same => n,Playback(tt-monkeys)
 same => n,Bridge(${bridge_this})
 same => n,Hangup()

exten => jump_called,1,NoOp()
 same => n,Set(MASTER_CHANNEL(bridge_this)=${CHANNEL})
 same => n,Wait(1000)
 same => n,Hangup()
Folse answered 4/2, 2014 at 3:21 Comment(0)
C
2

Who do you want to play the audio to, the caller or the callee?

You can use the M flag to Dial to run a macro on the call right before it's bridged, it runs on the callee SIP/200000. Example:

[testInComingCalls]
exten => 30953025,1,Dial(SIP/20000,20,M(onanswer))

[macro-onanswer]
exten => s,1,Playback(hello-world)
Cad answered 31/1, 2014 at 6:20 Comment(1)
I would like to play the recorded greeting message to the caller.Dunkin
Q
0

You need read info about AGI interface, which allow use php via phpagi to control dialplan.

http://www.voip-info.org/wiki/view/Asterisk+AGI

For playback file use STREAM FILE agi command($agi->stream_file in php)

Quantity answered 1/2, 2014 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.