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 client who is the bridged channel / 3rd party. We define listen, whisper, and barge as follows:
Listen: Monitor an agents call. The manager can hear both the agent and client channels, but no-one can hear the manager.
Whisper: Whisper to the agent. The manager can hear both the agent and client channels, and the agent can also hear the manager, but the client can only hear the agent, hence “whisper.”
Barge: Barge in on both channels. The manager channel is joined onto the agent and client channels, 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. This procedure varies from client to client (soft/hard phones))
One more note: We can also provide 3-way calling [live transfer] services on the server side, however this is outside the scope of this document. Please contact us for details.
Enough chit-chat, let’s get to the dialplan!
Note: In newer versions of FreePBX, custom includes are disabled by default.
This means that the new “ext-local-custom” or “from-internal-custom” context’s that we just created won’t be imported into the PBX “Brain”. To fix this, go to :
Settings->Advanced Settings
Find the “Dialplan and Operational” section, and change Disable -custom Context Includes?to False.
Be sure to click on the little checkbox that appears to the right to save the setting, then Apply Settings to rebuild the files. This is required or else the ext-local-custom context that we add won’t be included into the engine.
[ext-local-custom]
;listen
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},q)
exten => _*222x.#,n,Hangup
;whisper
exten => _*223x.#,1,Macro(user-callerid,)
exten => _*223x.#,n,Answer
exten => _*223x.#,n,NoCDR
exten => _*223x.#,n,Wait(1)
exten => _*223x.#,n,ChanSpy(sip/${EXTEN:4},qw)
exten => _*223x.#,n,Hangup
;barge
exten => _*224x.#,1,Macro(user-callerid,)
exten => _*224x.#,n,Answer
exten => _*224x.#,n,NoCDR
exten => _*224x.#,n,Wait(1)
exten => _*224x.#,n,ChanSpy(SIP/${EXTEN:4},qB)
exten => _*224x.#,n,Hangup
Let’s break it down:
Dialing *222970 would initiate listen on channel 970. *224401 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 => _*222x.# which will catch calls going to *222 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.6626″ 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.
Lastly we hangup to prevent a floating channel, and we’re done!
To monitor only specific channels, for example 8100 – 8199, set the chanprefix parameter like so:
;barge
exten => _*22481x.#,n,Chanspy(SIP/${EXTEN:4},qB)
This would let you monitor channels starting with SIP/81. (Potentially change SIP/ to Local/, Agent/, or whatever your channel type is)
This is a very simple method that will allow only a single extension the authority to barge. If you need to be able to manage a list of “authorized users”, then you should order our one of our commercial packages:
;barge
exten => _*224x.#/8001,1,Macro(user-callerid,)
exten => _*224x.#/8001,n,Answer
…
You can also use the same notation to repeat the above expression, so if you wanted to allow people with extensions 8000-8009 (ie managers or something), you could do: (Don’t forget the _ before the CID this time as it denotes a pattern.)
exten => _*224x.#/_800X,1,Macro(user-callerid,)
same => n,Answer
Ref: http://hackrr.com/2013/freepbx/adding-listen-whisper-and-barge-to-freepbx-or-asterisk/