1
votes

When a user makes a call to my pbx, he needs to enter another phonenumber. Then asterisk should call that number and when the owner of that number takes the phone, asterisk should play a sound.

The user who made the call to my pbx, can listen live to the other call, he will hear the sound played from the pbx and the sound of the user.

What is the best way to do this?

2
I have done it, well very similar thing, with Originate(). I can't explain now in detailes, maybe in few days, but read about Originatemirkobrankovic
Thank you. I've now used the Dial application with option G and the Spy on the call. It works but not 100%. I would like to see your way.Jochem Gruter

2 Answers

2
votes

Best(and simplest) way to do it - put user into conference and create enother 2 calls to same conference.

One with sound played, one call to other user(s).

For how to create call see this:

http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out

Chanspy will create structure similar to conference,but it much more simple control (mute/unmute) conference.

1
votes

Here is my solution

*I wrote it in AEL, much easier to understand

First I assume you got the callee number and file you want to play:

context Start 
{
  catch s {
            Wait(1);
            ...
            __NumberToDial=<Number that caller picked>;
            FileName=<File you want to play>;
            ...
            // I used SHARED variables to pass all the necessary data to sub channel
            SHARED(FileName)=${FileName};
            __Channel="${CHANNEL(name)}";
            Dial(Local/${CALLERID(num)}@Originate/n,,g);
  }
}

context Originate {
        _X. => { 
            Originate(SIP/<YourDialOutTrunk>/${NumberToDial},exten,Play,${Channel},1);
            if (${ORIGINATE_STATUS}!=SUCCESS)
            {
               //do stuff if not connected...
            }
            else
                    ChanSpy(,qsSg(${Channel}));
         }
}

context Play {
        _X. => {
                Channel="${CUT(EXTEN,?,1)}";
                Set(SPYGROUP=${Channel});
                FileName=${SHARED(FileName,${Channel})};
                Playback(${FileName});
         }
}

*add w option to ChanSpy if you want to allow whisper/talk
I didn't test this whisper!
You need to add catch => h everywhere and rest of the logic you need.
Whit this you will get the good timing. Only problem is to kill Originate channel if caller decide to hangup, which I've done sending channel kill on AMI with AGI script sending it channel name... bla bla... :)

Hope it helps :)