B.19. ChanSpy()

Enables eavesdropping on a channel.
ChanSpy([channelprefix[,options]])
Allows eavesdropping on a conversation on any specified channel (this is different from ZapBarge()/ZapScan() which are bound to Zap channels only). Note that this application only listens on single channels, rather than the conversation per se, even though it does capture incoming and outgoing audio on the channel.

Warning

Be aware that listening to calls may be subject to freedom of information and privacy legislation in your jurisdiction. As a matter of professional practice you should know the terms under which it is lawful to eavesdrop on telephone calls. In most jurisdictions it is illegal to eavesdrop on a call without the knowledge of the participants.
If channelprefix is specified, only channels with a name beginning with that string are available for listening.
Options may be combined:
b
(bridged) Restrict to bridged (i.e. connected) channels.
g(grp)
(group) Restrict to channels whose ${SPYGROUP} channel variable contains the value grp in a ":" (colon) delimited list.
q
(quiet) Do not play beep tones (nor announce the channel name) when switching channels.
r([name])
(record) Record the spying session in a file in the /var/spool/asterisk/monitor/ directory. The default filename prefix is chanspy.
v[(value)]
(volume) Set the initial volume. The range of allowed values is from -4 (quiet) bis 4 (loud).
w
(whisper) Activate whisper mode. Allows the user on the spying channel to speak to the channel user on the spied-on channel, without the remote user hearing. (This option is available as of Asterisk 1.4.)
W
(private whisper) Private whisper mode. Like w, except that the spying channel cannot hear the spied-on channel (it's not immediately clear where this would be useful, but Asterisk has found myriad applications!)
While listening, the following keypad input is accepted:
#
Increases volume stepwise (from -4 to 4)
*
Switches to another channel
X..X#
A set of digits of arbitrary length, ended with #, is attached to channelprefix. For example, if the extension invokes ChanSpy(Agent) and the user on the spying channel dials 1234#, the spying channel will begin spying on the channel Agent/1234.
; Eavesdrop on an agent:
exten => 123,1,ChanSpy(Agent)
exten => 123,n,Hangup()

; Example using g:
; for calls to 0, set SPYGROUP 10005:
exten => _0.,1,Set(SPYGROUP=10005)
;...
; Listen to channels in SPYGROUP 10005:
exten => 123,1,ChanSpy(,g(10005))
exten => 123,n,Hangup()

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'ChanSpy' =- 

[Synopsis]
Listen to a channel, and optionally whisper into it

[Description]
  ChanSpy([chanprefix][|options]): This application is used to listen to the
audio from an Asterisk channel. This includes the audio coming in and
out of the channel being spied on. If the 'chanprefix' parameter is specified,
only channels beginning with this string will be spied upon.
  While spying, the following actions may be performed:
    - Dialing # cycles the volume level.
    - Dialing * will stop spying and look for another channel to spy on.
    - Dialing a series of digits followed by # builds a channel name to append
      to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing
      the digits '1234#' while spying will begin spying on the channel
      'Agent/1234'.
  Options:
    b             - Only spy on channels involved in a bridged call.
    g(grp)        - Match only channels where their ${SPYGROUP} variable is set to
                    contain 'grp' in an optional : delimited list.
    q             - Don't play a beep when beginning to spy on a channel, or speak the
                    selected channel name.
    r[(basename)] - Record the session to the monitor spool directory. An
                    optional base for the filename may be specified. The
                    default is 'chanspy'.
    v([value])    - Adjust the initial volume in the range from -4 to 4. A
                    negative value refers to a quieter setting.
    w             - Enable 'whisper' mode, so the spying channel can talk to
                    the spied-on channel.
    W             - Enable 'private whisper' mode, so the spying channel can
                    talk to the spied-on channel but cannot listen to that
                    channel.
diff output to internal help in Asterisk 1.2:
5c5,6
< Listen to a channel, and optionally whisper into it
---
> Listen to the audio of an active channel
> 
9c10
< audio from an Asterisk channel. This includes the audio coming in and
---
> audio from an active Asterisk channel. This includes the audio coming in and
12c13
<   While spying, the following actions may be performed:
---
>   While Spying, the following actions may be performed:
17c18
<       the digits '1234#' while spying will begin spying on the channel
---
>       the digits '1234#' while spying will begin spying on the channel,
20,24c21,24
<     b             - Only spy on channels involved in a bridged call.
<     g(grp)        - Match only channels where their ${SPYGROUP} variable is set to
<                     contain 'grp' in an optional : delimited list.
<     q             - Don't play a beep when beginning to spy on a channel, or speak the
<                     selected channel name.
---
>     b - Only spy on channels involved in a bridged call.
>     g(grp) - Match only channels where their ${SPYGROUP} variable is set to
>              'grp'.
>     q - Don't play a beep when beginning to spy on a channel.
28,34c28,29
<     v([value])    - Adjust the initial volume in the range from -4 to 4. A
<                     negative value refers to a quieter setting.
<     w             - Enable 'whisper' mode, so the spying channel can talk to
<                     the spied-on channel.
<     W             - Enable 'private whisper' mode, so the spying channel can
<                     talk to the spied-on channel but cannot listen to that
<                     channel.
---
>     v([value]) - Adjust the initial volume in the range from -4 to 4. A
>                  negative value refers to a quieter setting.