ChanSpy with simultaneous Paging without blocking Dial execution

Does anyone know how to perform a ChanSpy simultaneously with paging without blocking a dial?

My goal is to monitor the fax-out channel via ChanSpy and listen to the ChanSpy via paging. I have already tried bevor it’s dial

same => n,Page(PJSIP/1005,qidb(outgoing^addHeader^1))

but then it gets stuck in the addHeader@outgoingcontext and the Dial command same => n,Dial(PJSIP/${NEW_EXTEN}@fax-out,20) is not executed within the fax-outcontext!

extensions.conf:

[fax-out]
exten => _0.,1,NoOp(Sending call to ${EXTEN})
same => n,Set(DEVICE_STATE(Custom:555)=INUSE) ; Hint for ChanSpy BLF
same => n,Set(CALLEEID=${EXTEN})
same => n,Set(CALLEEID=${CALLEEID:1})
same => n,Set(CALLEEID=+1${CALLEEID})
same => n,Set(CLEANED_NUMBER=${EXTEN})
same => n,Set(FAXOPT(gateway)=yes)
same => n,Set(CALLERID(num)=+1 23 45 67 89)
same => n,Set(NEW_EXTEN=0${EXTEN:1})
< — HERE I WANT PAGEGING AND CHANSPY WITHOUT BLOCKING DIAL FOR FAX-OUT (maybe my existing extensions 500 and 2000 ?) —>
same => n,Dial(PJSIP/${NEW_EXTEN}@fax-out,20)
same => n,Hangup()
exten => h,1,Set(DEVICE_STATE(Custom:555)=NOT_INUSE)

[outgoing]
exten => 2000,1,Answer()
exten => addHeader,1,Set(PJSIP_HEADER(add,Call-Info)=“;answer-after=0)”)
same => n,Return()
exten => 2000,n,Page(PJSIP/1005,qidb(outgoing^addHeader^1))

[outgoing]
exten => 555,1,Answer()
same => n,ChanSpy(PJSIP/fax-,q) ; Channels begins with “fax-” only
same => n,Hangup()

Something like this also doesn’t work:

exten => _0.,2,Dial(PJSIP/${NEW_EXTEN}@fax-out,20,G(3))
exten => _0.,3,Page(PJSIP/1005,qidb(outgoing^addHeader^1))

Page and ChanSpy both block. Instead you would have to Originate[1] a new call that does stuff on its own, using a Local channel[2] which would send both ends into the dialplan.

[1] Originate - Asterisk Documentation
[2] Overview - Asterisk Documentation

1 Like

Thank you, that’s pretty cool and I didn’t know. When my hylafax dials fax-out context in asterisk, my phone activates paging and I can hear the ongoing fax!

Now my dialplan looks like this:

[fax-out]
exten => _0.,1,NoOp(Sending call to ${EXTEN})
same => n,Originate(Local/2000@outgoing,exten,outgoing,555,1)
same => n,Set(DEVICE_STATE(Custom:555)=INUSE) ; Hint for ChanSpy BLF
same => n,Set(CALLEEID=${EXTEN})
same => n,Set(CALLEEID=${CALLEEID:1})
same => n,Set(CALLEEID=+1${CALLEEID})
same => n,Set(CLEANED_NUMBER=${EXTEN})
same => n,Set(FAXOPT(gateway)=yes)
same => n,Set(CALLERID(num)=+1 23 45 67 89)
same => n,Set(NEW_EXTEN=0${EXTEN:1})
same => n,Dial(PJSIP/${NEW_EXTEN}@fax-out,20)
same => n,Hangup()
exten => h,1,Set(DEVICE_STATE(Custom:555)=NOT_INUSE)