How to chanspy specific extension in Freepbx ?

Freepbx has Chanspy feature by which you can dial feature code 555 from phone extension and randomly barge any user who is on a call. This doesn’t have any privilege and any one can do it.
So for listening to the conversation of the specific user so that we can dial a particular feature code which is authenticated and then select the particular extension whose call you want listen.

Solution:

Follow the below steps

Step1

First disable the feature code chanspy 555 option in Freepbx. Look under Basic – Feature codes and set the feature status for Chanspy to disabled.

Step2

Next go to /etc/asterisk/extensions_custom.conf and add the following code in it:

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