Playback() to calling party after called party has answered

Hi

I am developing a call service for my company that shall be able to answer any incoming call from anywhere in the world.

Basically it works like this; the calling party (A) calls in to our asterisk (*) which plays a menu of choices and if all input entries are correct, ends up with a Dial() to C (called party). An info message will be played to C before A and C are connected.

Everything works fine, except that we want a feature that provides audio feedback to both calling party and called party after the called party has answered. The reason for this is while the info message is played for C, all A can hear is silence. Which we are afraid will confuse the calling party resulting in A hanging up before A and C are connected with audio.

I have tried different solutions, and for the called party there are no issues. I can use both the A(x) option or the M(macro) option and the correct message is played to the called party when call is answered.
My challenge is to play a message to the calling party(A) after C has answered.

I have tried the G() option, but I cannot make it to work properly. It solves one problem, but creates a new one.

Problem solved: Yes, soundfile can be played to both A and C after C has answered.
New problem: Both ends do hangup() instead of connecting after extension completes.

I don’t quite understand how the G() option is meant to work. So if someone knows, please educate me. I guess the Bridge() function might be the solution, but I could not get that to work either…

Here’s the code for my G() option which does not work:

...Answer()
...some menu code...
...that ends up in dial...
exten => ....
exten => ....
same =>  n,Dial(Technology/Resource,90,G(msg,1))

; Dial message helper
exten =>    msg,1,Goto(anum,1)
exten =>    msg,2,Goto(cnum,1)

; Playback message to calling party
exten =>      anum,1,Playback(soundfile_to_calling_party)

; Playback message to calling party
exten =>      cnum,1,Wait(2)
exten =>      cnum,n,Playback(soundfile_to_called_party)
exten =>      cnum,n,Wait(1)

I will really appreciate some feedback and help.

Until then, our asterisk is set up to use the M() option and only inform C while A listens to the lovely silence until A and C get connected with audio…

exten => ....
same =>  n,Dial(Technology/Resource,90,M(play_message))

[macro-play_message]
exten => s,1,Wait(2)
exten => s,n,Playback(info_message)
exten => s,n,Wait(1)

core show application Bridge

Note, this should have been asked on Asterisk Support.

Thank you. I am aware of the Bridge() application and I have read the documentation but did not understand it, so I am interested in an example and how it works if I use the G() option in Dial().

Or an example to solve this in another way.

Thanks.

btw:
Is it any way I can move this post to Asterisk Support if that is where this question belongs?

Wait on one branch of the G. Do the playback on the other. When the playback is over, bridge to the waiting channel.

Thank you david55 for answering me.
Just to make sure I have understood it correct.
In my example, if the soundfile_to_called_party last for 7 seconds, the total cnum extention will take 10 seconds. If the soundfile_to_calling_party last for 4 seconds I must wait additional 6 seconds before bridging happens(?) or should I wait longer?

The ${CHANNEL} variable as I understand is default to the calling party channel(?), in this case related to anum(?) so then in order for Bridge() to work properly, cnum must bridge it’s channel with anum, like:

...Answer()
...some menu code...
...that ends up in dial...
exten => ....
exten => ....
same =>  n,Dial(Technology/Resource,90,G(msg,1))

; Dial message helper
exten =>    msg,1,Goto(anum,1)
exten =>    msg,2,Goto(cnum,1)

; Playback message to calling party
exten =>      anum,1,Playback(soundfile_to_calling_party)
exten =>      anum,n,Wait(6)

; Playback message to calling party
exten =>      cnum,1,Wait(2)
exten =>      cnum,n,Playback(soundfile_to_called_party)
exten =>      cnum,n,Wait(1)
exten=>       cnum,n,Bridge(${CHANNEL})

If I have misunderstood this, please provide me example code. I have spent hours and hours reading documentation, trying different things, and just cannot get it right…

What I cannot get my head around is if ${CHANNEL} is the calling party channel, the called party channel will always be dynamic, so how to get the called party channel and set it to a variable I can use in Bridge(channel)?

The documentation says:
channel - The current channel is bridged to the specified channel.

Does the current channel in my case mean the anum channel? In that case, I guess that channel is already in use and I cannot bridge to that channel, so that won’t work(?).
Which brings me back to how to get the dynamic outgoing called channel?
If I can get that, I guess I will know which to channels to bridge.

I’m confused. Please help.
Thank you in advance.

It doesn’t matter if you wait longer than needed, as the wait will be cancelled by the Bridge.

Bridge will generate a masquerade and will terminate the dialplan on the target.

You do want the anum channel, which you could copy to an inheritable (_) channel variable before the dial.

Sorry, but providing working code falls into full consultancy, as I need to test it, etc. I’m not in a position where it is practicable to bill for small amounts of international consultancy.

Following “basic and untested” code should work.

…Answer()
…some menu code…
…that ends up in dial…
exten => …
exten => …
same => n,Set(__ORIGCHANNEL=${CHANNEL})
same => n,Dial(Technology/Resource,90,G(msg,1))

; Dial message helper
exten => msg,1,Goto(anum,1)
exten => msg,2,Goto(cnum,1)

; Playback message to calling party
exten => anum,1,Playback(soundfile_to_calling_party)
exten => anum,n(waitagain),Wait(6)
exten => anum,n,Goto(waitagain)

; Playback message to called party
exten => cnum,1,Playback(soundfile_to_called_party)
exten=> cnum,n,Bridge(${ORIGCHANNEL})

–Satish Barot
satish4asterisk@gmail.com