Adding LISTEN, WHISPER, BARGE to ASTERISK for SIP and PJSIP

sachin
edited January 2022 in asterisk

For the purpose of this article, we will define manager as the caller 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.

This should be placed in /etc/asterisk/extensions_custom.conf

[ext-local-custom]

;listen
exten => _*222x.#,1,Answer()
exten => _*222x.#,2,NoCDR()
exten => _*222x.#,3,Wait(1)
exten => _*222x.#,4,AGI(${FASTAGI}/outb_spy.php,listen)
;For SIP
exten => _*222x.#,5,ChanSpy(SIP/${EXTEN:4},q)
;For PJSIP (comment above line and uncomment below)
;exten => _*222x.#,5,ChanSpy(PJSIP/${EXTEN:4},q)
exten => _*222x.#,6,Hangup()

;whisper
exten => _*223x.#,1,Answer()
exten => _*223x.#,2,NoCDR()
exten => _*223x.#,3,Wait(1)
exten => _*223x.#,4,AGI(${FASTAGI}/outb_spy.php,whisper)
;For SIP
exten => _*223x.#,5,ChanSpy(SIP/${EXTEN:4},qw)
;For PJSIP (comment above line and uncomment below)
;exten => _*223x.#,5,ChanSpy(PJSIP/${EXTEN:4},qw)
exten => _*223x.#,6,Hangup()

;barge
exten => _*224x.#,1,Answer()
exten => _*224x.#,2,NoCDR()
exten => _*224x.#,3,Wait(1)
exten => _*224x.#,4,AGI(${FASTAGI}/outb_spy.php,barging)
;For SIP
exten => _*224x.#,5,ChanSpy(SIP/${EXTEN:4},qB)
;For PJSIP (comment above line and uncomment below)
;exten => _*223x.#,5,ChanSpy(PJSIP/${EXTEN:4},qw)
exten => _*224x.#,6,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.

In 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.

Tagged:
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!