Get a call to recall, or fail the transfer so it will recall

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 (21.9.1) 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.

Transfer won’t work because the caller’s system won’t know anything about how you name endpoints in your system. Transfer needs a URI. It’s also possible that phones are configured to ignore Transfers, as they can be used to inject toll calls at your expense.

Ir all you have is the endpoint name, you need to use Dial.

Ok, thanks for the explanation on that. I wasn’t thinking that way, but it makes sense. I changed it to

same => n,Dial(${ORIGINATOR},30,${DIAL_OPTIONS})

And it sort of works, when I tried it with a Yealink phone, the call would not ring, although the other phone I have registered on that account does (not a Yealink). Not sure why the Yealink will not ring. Maybe it’s because I have more than one phone registered to my extension, and Dial only sends it to the first one?

According to the log, the Dial looks like this -

-- Executing [399@page-timeout:9] Dial(“PJSIP/Clearfly-00006b06”, “PJSIP/1209,30,TtrcI”) in new stack

Well, I then remember something else, I am dealing with findme, so I remembered I have to use this -

same => n,Goto(from-did-direct,${ORIGINATOR},1)

That ended up working. Don’t know why I did not think of that before. I guess it sometimes takes a nudge from someone else to figure it out.

Thanks