ChanSpy on a running calls

I’m originating two external calls using Asterisk call file. Now I need to allow a supervisor to listen the call. ChanSpy can be a way but cannot understand how to achieve that. Can anyone give an idea?

You could “mark” these outgoing channels you want to spy on with the “SPYGROUP” variable:


Then, you create an internal extension which can be called by your phone.
There you start application ChanSpy() with parameter “g” and your group name.
Do not use the group name as the first parameter, that one needs to be empty in that case!


If there is more than one channel with that group, you can cycle through them by pressing * on your phone.

Thanks for your suggestions.
Can I set that from Call File anyway? I’m aware of setting the same from Dialplan, but cannot understand how to do that from Call File.

For anything complex from a callfile, you use a local channel, which gives you dialplan.

What happened when you tried? What error message did you get?

Well, in Call File, I’m using the following context

exten => _+X.,1,Set(CALLERID(all)=+91XXXXXXXXXX)
same => n,NoOp(IFI_UUID: ${IFI_UUID})
same => n,NoOp(EXTEN: ${EXTEN})
same => n,NoOp(UNIQUEID: ${UNIQUEID})
same => n,NoOp(CHANNEL: ${CHANNEL})
same => n,NoOp(IFI_AGENT: ${IFI_AGENT})
same => n,Set(CDR(userfield)=${IFI_AGENT})
same => n,Set(SPYGROUP=759)
same => n,AGI(, ${IFI_UUID}, ${EXTEN}, ${UNIQUEID})
same => n,Goto(from-internal,${EXTEN},1)

And trying to access the SpyGroup the following way (I copied the example from somewhere else, I wanted to call 2759 to listen the 759 group.

exten => _2759.,1,Gosub(sub-my-chanspy,s,1(${EXTEN:4}))

exten => s,1,Macro(user-callerid,)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n,ChanSpy(,g(759))
exten => s,n,Hangup

And I’m getting “The call cannot be completed as dialled” message.

Can you please guide me to fix this?

Please provide the asterisk logs at at least verbosity 3.

And the contents of the call file.

For any future reader…

Both SPYGROUP and CDR(userfield) can be set in the call file.

Can you please guide how to set both within CallFiles?

Using Setvar, as for any other variable.

Tried and that worked. Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.