Adding Listen, Whisper, and Barge to FreePBX or Asterisk

If you are running a call center on FreePBX or Asterisk, most likely you will want the ability to listen in on agents calls, also known as joining multiple calls, or connected two calls to a manager, or other variations of barging in on a bridged channel.

For the purpose of this article, we will define manager as the callee who is the spying channel, agent who is the spied-on channel, and caller who is the bridged channel. We define listen, whisper, and barge as follows:

Listen: Monitor an agents call. The manager can hear both the spied-on and bridged channels, but they cannot hear the manager.

Whisper: Whisper to the agent. The manager can hear both the spied-on and bridged channels, and the spied-on channel (agent) can also hear the manager, but not the bridged channel, hence “whisper.”

Barge: Barge in on both channels. The manager channel is joined onto the spied-on and bridged channel, and all parties can hear each other. Be warned, if the original agent leaves the call, the call is dropped. This is not a 3-way call. (However you can barge in, and when comfortable, initiate a 3way call to your extension so you can continue the call without the agent.

let’s get to the dialplan!

[Dialing-Phones]

;listen
exten => _*111x.#,1,Macro(user-callerid,)
exten => _*111x.#,n,Answer
exten => _*111x.#,n,NoCDR
exten => _*111x.#,n,Wait(1)
exten => _*111x.#,n,ChanSpy(sip/${EXTEN:4},q)
exten => _*111x.#,n,Hangup

;whisper
exten => _*222x.#,1,Macro(user-callerid,)
exten => _*222x.#,n,Answer
exten => _*222x.#,n,NoCDR
exten => _*222x.#,n,Wait(1)
exten => _*222x.#,n,ChanSpy(sip/${EXTEN:4},qw)
exten => _*222x.#,n,Hangup

;barge
exten => _*333x.#,1,Macro(user-callerid,)
exten => _*333x.#,n,Answer
exten => _*333x.#,n,NoCDR
exten => _*333x.#,n,Wait(1)
exten => _*333x.#,n,ChanSpy(SIP/${EXTEN:4},qB)
exten => _*333x.#,n,Hangup

Let’s break it down:
Dialing *111970 would initiate listen on channel 970. *333401 would barge in on 401′s call speaking to both parties.

We start by finding (or adding) the ext-local-custom context, and declaring: exten => _*111x.# which will catch calls going to *111 followed by a sequence of numbers.

We define the first line with priority 1, and initiate Macro(user-callerid,) which basically sets the environment and loads up details about the extension, like caller id, and display name.

On the 2nd and subsequent lines, we start them the same way, and instead set priorty to n, this will let asterisk generate priorities automatically, so you don’t always have to change each priority just to add new code.

Expert Tip: We could have used same => n,Answer() and continued to use same. This is shorthand that was added later to asterisk, and just simplifies it that much more.

We answer the call on priority 2, then we tell asterisk’s cdr_mysql module not to store this “call” as a CDR record.

We wait a second with Wait(1) to give everything time to get ready, then we initialize the ChanSpy app. There are various options you can use, we chose q (which prevents “SIP.1000″ or whatever from being spoken when you start spying.) w, which is “whisper mode”, and B which is barge. Do not get this confused with b (lowercase) which is for only joining bridged calls.INET-EXPERT-TECHNOLOGY 2

 

Leave a Reply