Jochem Gruter
Jochem Gruter

Reputation: 2899

PBX Call makes another call and spy

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?

Upvotes: 0

Views: 473

Answers (2)

mirkobrankovic
mirkobrankovic

Reputation: 2347

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 :)

Upvotes: 1

arheops
arheops

Reputation: 15259

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.

Upvotes: 2

Related Questions