Skip to content

Monitoring Agents in Asterisk with ChanSpy

by Jon on October 29th, 2009

When using asterisk in a call center environment there is always a need to be able to listen to the representatives and monitor their calls. An easy way to accomplish this in asterisk is with the built in function, chanspy. There are many uses for chanspy but I am only going to show you a few. The configurations I am showing you are ones that I commonly use for my clients. One function of chanspy that my clients like to use is the ability to do scanning, this allows a manager to dial into the phone system and scan through all the agents in their queue. I will also show you how to directly dial into an agents phone to listen to them so you will be able to pick out specific extensions you would like to listen to.

Example 1: Scanning all live extensions on the phone system. Place this in your [internal] context.

Chanspy Scanning
exten => 8888,1,Chanspy(‘all’|qb)

Once this is accessible by the phones on your system just dial 8888 from any phone and then use # to scan channels.

Example 2: Using spy groups to scan specific groups of agents or queues.

[default] ;this is how you would route calls to use the spy group
exten => 5553129900,1,Answer
exten => 5553129900,n,Set(SPYGROUP=3300)
exten => 5553129900,n,Set(CDR(accountcode)=voip_ib_${CALLERID(DNID)})
exten => 5553129900,n,Set(CALLERID(name)=inboundcall)
exten => 5553129900,n,Queue(8000|twW)

[internal] ;Chanspy Scanning
exten => 883300,1,Chanspy(,g(3300))
exten => 883300,n,Hangup()

Now try dialing 883300 from any phone on the system and you can scan through the agents on live calls in the spy group.

Example 3: This example will give the ability to dial directly into an agents phone to listen to them.

[internal] ;Chanspy Direct SIP Extension
exten => _88XXXX,1,Chanspy(SIP/${EXTEN:2}|b)

Here you can dial directly into any agents 4 digit phone extension and listen to them, for example if you wanted to listen to sip extension 5400 then dial 88+5400. That would dial directly into monitoring phone extension number 5400. If your phones only have 3 digits remove one of the “X”‘s from the exten line.

From → VOIP

  1. Bookmarked your web site. Thank you for sharing. Definitely worth the time away from my workload.

  2. Brandon Fahnestock permalink

    Is this possible to implement on a Trixbox 2.8 installation. If so, could you give me a little guidance?

    • Yes this can be implemented on trixbox. You will need to create a custom context and then add that context in extensions-custom.conf, if you need a step by step I would be able to create that for you.

      • Jun permalink

        Hi Jon,

        Can you also provide me a step by step how to do this. I need chanspy that can directly on extension.


        • Hi Jun,

          If you want to Chanspy on a direct extension use the following code: (2521 is the example extension number I am using below)

          exten => _82521,1,Chanspy(SIP/2521|b)

          You will need to put this in your local dialplan which will most likely be [internal], then you can dial 82521 from any local phone to listen to extension 2521 if they are on a call.

          Hope this helps, there are directions in the post on how to chanspy on dynamic extensions.



  3. Ahmed permalink

    Just bookmarked this site, excellent addition to my asterisk resources!

    How could I have the user chanspy by selecting an extension from a specified extension list or group?

  4. Richard Welsing permalink

    I am new to this and i have a customer who wants to spy on specific extentions.

    Can you please walk me through on how to do this “Place this in your [internal] context.” exactly.

    with commands.


Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: