5

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.

Shyju Pulari
  • 149
  • 1
  • 2
  • 11

3 Answers3

5

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()
Matt Jordan
  • 2,899
  • 1
  • 27
  • 29
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)
Tim
  • 4,999
  • 3
  • 24
  • 29
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)

arheops
  • 15,544
  • 1
  • 21
  • 27