ChanSpy - Customization in FreePBX

Hi,

We are looking into listening in on conversations with our asterisk server and I have read that ChanSpy does just that. I enabled it on freePBX and I was able to cycle trough all the active calls by pressing * but I was having a difficult time trying to go to a specific call.

We also needed a way to make it password protected. After doing some searching I found that if I put this in the extensions.conf file it should work.

[code:1]
exten => 555,1,Authenticate(1234)
exten => 555,2,Read(SPYNUM,extension)
exten => 555,3,ChanSpy(SIP/${SPYNUM},q)
[/code:1]

but it wouldn’t work and I think it had to do with freepbx already has ChanSpy integrated in the files. I found out that in the extensions_additional.conf there is the following to enable ChanSpy:

[code:1]
[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Macro(user-callerid,)
exten => 555,n,Answer
exten => 555,n,Wait(1)
exten => 555,n,ChanSpy()
exten => 555,n,Hangup
; end of [app-chanspy]
[/code:1]

I modified this section so it looks like this:

[code:1]
[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Authenticate(1234)
exten => 555,2,Read(SPYNUM,extension)
exten => 555,3,ChanSpy(SIP/${SPYNUM},q)

;old code
;exten => 555,1,Macro(user-callerid,)
;exten => 555,n,Answer
;exten => 555,n,Wait(1)
;exten => 555,n,ChanSpy()
;exten => 555,n,Hangup

; end of [app-chanspy]
[/code:1]

It works great, by dialing 555 it asks for a password and then it asks for the extension and then connects me to it if there is a call. This is exactly what we need, but I found out everytime I make a change in the freePBX system and reload the changes it erases my changes.

I have tried to disable the ChanSpy in FreePbx and then stick this code in extensions.conf and extensions_custom.conf but it doesn’t work at all it just gives me a 484 error on my phone.

Is there any way I can get ti so when I reload the changes in freepbx it keeps my changes on the ChanSpy, or is there a new update that lets me add authentication and jump to a certain extension in ChanSpy in freePBX?

Also one more question does anyone know how to disallow a certain extension(s) from ChanSpy. The CEO doesn’t want anyone listening to his calls and with ChanSpy they would.

Thanks
Blake

I’ve made a custom ChanSpy context:

[code:1][app-chanspy-custom]
exten => 5555,1,Answer
exten => 5555,2,Wait(1)
exten => 5555,3,Goto(custom-app-enh-chanspy,s,1)
exten => 5555,4,Hangup

[custom-app-enh-chanspy]
exten => s,1,BackGround(please-enter-the)
exten => s,n,Read(SPYNUM|extension)
exten => s,n,ChanSpy(SIP/${SPYNUM}|w)[/code:1]

Works okay, except when I enabled the User Login/Logoff feature codes. How do I ChanSpy a user that has logged into his or her phone via the *11 feature code without knowing his device number?

Let’s say User 4004 is logged into Device 2002. Instead of entering 2002, I would like to enter 4004 instead. Any leads on how to do this?

Thanks![/code]

p_lindheimer,

Is there anyway I can stick it in a different config file in the meantime so I can use FreePBX and not have to worry about changing these lines of code everytime?

I am going to try to implement groups on the ChanSpy so that it will only look at certain extensions and not having to change the config files everytime I want to update FreePBX settings would be nice.

Thanks
Blake

you will have to modify the extensions.conf file and put an include before extensions_additional.conf and then define it in that file. That will take precedence over extensions_additional.conf. However, upgrading to a new version will overrite your extensions.conf file (although it is just one include statement).

This is rectified in 2.3 (which is still svn/trunk):

http://freepbx.org/trac/ticket/1997#comment:1

you can click on the link to the change to see how it was added.

p_lindheimer,

Thanks for your help
Blake

I tried moving the block of code in a seperate config file (below)

extensions_chanspy.conf

[code:1]
; ChanSpy configuration

[chanspy]
include => app-chanspy-custom

;exten => 555,1,Authenticate(1234)
;exten => 555,2,Read(SPYNUM,extension)
;exten => 555,3,ChanSpy(SIP/${SPYNUM},q)

;old code
exten => 555,1,Macro(user-callerid,)
exten => 555,n,Answer
exten => 555,n,Wait(1)
exten => 555,n,ChanSpy()
exten => 555,n,Hangup

; end of [app-chanspy]
[/code:1]

and then in the extensions.conf file I added an include before extensions_additional.conf.

[code:1]; FreePBX
; Copyright © 2004 Coalescent Systems Inc (Canada)
; Copyright © 2006 Why Pay More 4 Less Pty Ltd (Australia)
; Released under the GNU GPL Licence version 2.

; dialparties.agi (http://www.sprackett.com/asterisk/)
; Asterisk::AGI (http://asterisk.gnuinter.net/)
; gsm (http://www.ibiblio.org/pub/Linux/utils/compress/!INDEX.short.html)
; loligo sounds (http://www.loligo.com/asterisk/sounds/)
; mpg123 (http://voip-info.org/wiki-Asterisk+config+musiconhold.conf)

; include extensions contexts for chanspy
#incluce extensions_chanspy.conf

; include extension contexts generated from AMP
#include extensions_additional.conf

; Customizations to this dialplan should be made in extensions_custom.conf
; See extensions_custom.conf.sample for an example
#include extensions_custom.conf
[/code:1]

I am having troubles trying to get SPYGROUP working with freepbx and ChanSpy. On the documentation for ChanSpy it says I can assign extensions to the SPYGROUP and then I will only be able to listen in on the extensions in the group. For eacmple below is the sample configuration to setup a spygroup for sales and for crm.

[code:1]
[crm-agents-site2]
exten => _[1-6]XXX,1,SetVar(SPYGROUP=CRM)
exten => _[1-6]XXX,2,Dial(IAX2/g2/${EXTEN},15,tTwW)

[sales-agents-site2]
exten => _[1-6]XXX,1,SetVar(SPYGROUP=SALES)
exten => _[1-6]XXX,2,Dial(IAX2/g2/${EXTEN},15,tTwW)

[app-chanspy-crm-agents]
exten => _*53,1,SetVar(SPYGROUP=CRM)
exten => _*53,2,ChanSpy(|g(CRM)q)

[app-chanspy-sales-agents]
exten => _*54,1,SetVar(SPYGROUP=SALES)
exten => _*54,2,ChanSpy(|g(SALES)q)
[/code:1]

I would like to implement something like this in freepbx or at least modify the configuration files so it would be possible. Does anyone know if I could make these changes without losing my configuration each time I change something in freepbx?

blakegrover,

you are right that chanspy and several others should have the option of being password protected. Please enter a ticket into our trac system against 2.3-branch to have this done. zapbarge would also fit in this category and there are probably a few others.

you can also put in the request to make chanspy work with a specific extensions by appending the extension number after the feature code. I have done this and it works IIRC it was this (should probably check that the extension is a sip extension though)

[code:1]
exten => _555X.,1,Macro(user-callerid,)
exten => _555X.,n,Answer
exten => _555X.,n,Wait(1)
exten => _555X.,n,ChanSpy(SIP/${EXTEN:3})
exten => _555X.,n,Hangup
[/code:1]
So please put in the requests and we can try and see what we can do.

Erol:

I took what you started and to get it to stick, even after “Apply Configuration Changes” would normally reset the extensions_additional.conf section of [app-chanspy], I just added the following to the extensions_custom.conf:

[from-internal-custom]

exten => 779,1,Macro(user-callerid,)
exten => 779,1,Authenticate(1234)
exten => 779,2,Read(SPYNUM,tt-monkeys)
exten => 779,3,ChanSpy(SIP/${SPYNUM})

Since I’m not using “555” it doesn’t conflict with the [app-chanspy] section, and since it’s in the _custom.conf file, it doesn’t get over-written when Applying changes. I used “779” because it corresponds with the letters “SPY” on the phone.

Anyway - so far, it seems to be working well for me. I have a room of about 25 people, and it’s making the QC managers’ lives much easier. I do have a question for you though…we have 7 rows of desks. I numbered the first desk of each row 5x1, where row 1 is 511, row two is 521, row three is 531 and so on, that way, the manager can just dial 533 to get the 3rd desk in the 3rd row, and so on. He liked the ability to scan via ChanSpy, but he didn’t like that he couldn’t start where he wanted. Can you think of anyway to ChanSpy into 531, then by hitting the “*” key scan through the rest of the 53x’s? That way he could just enter a row, and stay there?

Let me know if that makes any sense, and if you have any way to implement that.

Thanks! Without your code sample, I’d still be fighting with this user request!

David

VFRDavid has a nice solution. We decided to disable ChanSpy under “Feature Code”.

Then we added extension 555 to extensions_custom.conf.

exten => 555,1,Macro(user-callerid)
exten => 555,2,Authenticate(1234)
exten => 555,3,Read(SPYNUM,agent-newlocation)
exten => 555,4,ChanSpy(SIP/${SPYNUM))

Reloads and updates won’t make this fade. The “agent-newlocation” fits better than the tt-monkeys :wink:

I also looked into blakegrover’s problem. It would be nice if you could put all the extensions in one group and exclude some in a group, so admin’s are able to listen and users are not. Maybe this will help you http://www.panoramisk.com/64/real-time-call-listening/en/.

too bad it isn’t possible to set a different chanspy password for a specific user…

To have different users authenticate with their own password try some of the options at these links
http://www.voip-info.org/wiki/view/Asterisk+cmd+VMAuthenticate
http://www.voip-info.org/wiki/view/Asterisk+cmd+Authenticate

Robin

I’m sorry for this stupid question but how do u use this :blush: It is not an asterisk command is it? I entered ‘help’ in the asterisk command and i couldn’t find it. My guess it that u have to use it in a config file, but which one :blush:

no one?

someone out there?