Custom Dialplan; recall call or fail the transfer

I am working on a context that will check whether the call is transferred; if so, send it back, as I only want to accept original calls, not transferred ones. i.e., for paging so that calls don’t accidentally get transferred to the paging system. This is a FreePBX system, but more of an Asterisk question. This is what I have -

[page-timeout]
exten => _.,1,Noop(Page Timeout)
same => n,NoOp(Checking if call to paging is a transfer)
same => n,GotoIf($[${VARIABLE_EXISTS(BLINDTRANSFER)}]?transfer_blocked)
same => n,Set(TIMEOUT(absolute)=10)
same => n,Goto(app-pagegroups,${EXTEN},1)
same => n(transfer_blocked),NOOP(Recall Blind Call)
same => n,Set(ORIGINATOR=${CUT(BLINDTRANSFER,-,1)})
same => n,Wait(4)
same => n,Transfer(${ORIGINATOR})
same => n,Hangup()
exten=> h,1,Return

It works, sort of. The transfer is detected and blocked, but instead of the call ringing back, the call drops.

Executing [398@from-internal-xfer:6] Goto(“PJSIP/Clearfly-00006ac9”, “page-timeout,399,1”) in new stack
– Goto (page-timeout,399,1)
– Executing [399@page-timeout:1] NoOp(“PJSIP/Clearfly-00006ac9”, “Page Timeout”) in new stack
– Executing [399@page-timeout:2] NoOp(“PJSIP/Clearfly-00006ac9”, “Checking if call to paging is a transfer”) in new stack
– Executing [399@page-timeout:3] GotoIf(“PJSIP/Clearfly-00006ac9”, “1?transfer_blocked”) in new stack
– Goto (page-timeout,399,6)
– Executing [399@page-timeout:6] NoOp(“PJSIP/Clearfly-00006ac9”, “Recall Blind Call”) in new stack
– Executing [399@page-timeout:7] Set(“PJSIP/Clearfly-00006ac9”, “ORIGINATOR=PJSIP/1209”) in new stack
– Executing [399@page-timeout:8] Wait(“PJSIP/Clearfly-00006ac9”, “4”) in new stack
– Executing [399@page-timeout:9] Transfer(“PJSIP/Clearfly-00006ac9”, “PJSIP/1209”) in new stack
> 0x7ff4cc12ba10 – Strict RTP learning after remote address set to: 0.0.0.0:47236
– Executing [399@page-timeout:10] Hangup(“PJSIP/Clearfly-00006ac9”, “”) in new stack
== Spawn extension (page-timeout, 399, 10) exited non-zero on ‘PJSIP/Clearfly-00006ac9’
– Executing [h@page-timeout:1] Return(“PJSIP/Clearfly-00006ac9”, “”) in new stack
– Executing [s@macro-dial:34] Set(“PJSIP/Clearfly-00006ac9”, “DIALSTATUS=ANSWER”) in new stack
– Executing [s@macro-dial:35] GosubIf(“PJSIP/Clearfly-00006ac9”, “1?ANSWER,1()”) in new stack
– Executing [ANSWER@macro-dial:1] NoOp(“PJSIP/Clearfly-00006ac9”, “Call successfully answered - Hanging up now”) in new stack
– Executing [ANSWER@macro-dial:2] GotoIf(“PJSIP/Clearfly-00006ac9”, “0?,”) in new stack
– Executing [ANSWER@macro-dial:3] GotoIf(“PJSIP/Clearfly-00006ac9”, “0?,return,1”) in new stack
– Executing [ANSWER@macro-dial:4] NoOp(“PJSIP/Clearfly-00006ac9”, “checking something else to do ?? IVR return!!”) in new stack
– Executing [ANSWER@macro-dial:5] Gosub(“PJSIP/Clearfly-00006ac9”, “macro-hangupcall,s,1()”) in new stack
– Executing [s@macro-hangupcall:1] Set(“PJSIP/Clearfly-00006ac9”, “__MCVMSTATUS=”) in new stack
– Executing [s@macro-hangupcall:2] Gosub(“PJSIP/Clearfly-00006ac9”, “app-missedcall-hangup,s,1()”) in new stack
– Executing [s@app-missedcall-hangup:1] NoOp(“PJSIP/Clearfly-00006ac9”, “Dialed: s”) in new stack
– Executing [s@app-missedcall-hangup:2] NoOp(“PJSIP/Clearfly-00006ac9”, "Caller: ") in new stack
– Executing [s@app-missedcall-hangup:3] GotoIf(“PJSIP/Clearfly-00006ac9”, “0?exit”) in new stack
– Executing [s@app-missedcall-hangup:4] Set(“PJSIP/Clearfly-00006ac9”, “EXTENNUM=s”) in new stack
– Executing [s@app-missedcall-hangup:5] Set(“PJSIP/Clearfly-00006ac9”, “FEXTENNUM=s”) in new stack
– Executing [s@app-missedcall-hangup:6] GotoIf(“PJSIP/Clearfly-00006ac9”, “0?exit”) in new stack

I have tried using Dial() instead of Transfer(), and I get basically the same result. The phone rings back, but the call drops, and when you pick up, the call is not there. I am not sure why, I have the h extension set to Return because if I remove it, the dialplan runs twice because it is called with a h on Hangup(), but I get the same result either way. I assume I’m misunderstanding something, but I can’t figure out why I can’t get the call to recall.

Multiposted as Get a call to recall, or fail the transfer so it will recall - Asterisk Dialplan - Asterisk Community