Call Forward Macro


Due to the default nature of Asterisk call forwarding which does not suit my needs (anyone can forward any phone without any authentication) I have written my own macro which works very well in simplifying the whole process. However it does not check to see if the remote end has any forwards which may cause a loop if it’s set to forward back to itself.

I can’t get this to work. Can anyone point me in the right direction for this?

This is my macro for a immediate forward:

;sets a immediate forward
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(call-fwd-unconditional)
exten => s,n(startread),Playback(ent-target-attendant)
exten => s,n,Read(toext,then-press-hash,)
exten => s,n,GotoIf($[${toext:0:1} = 9]?external:internal)
exten => s,n(internal),Set(DB(CF/${AMPUSER})=${toext})
exten => s,n,Playback(auth-thankyou&goodbye)
exten => s,n,Macro(hangupcall,)
exten => s,n(external),Set(DB(CF/${AMPUSER})=77${toext})
exten => s,n,Playback(auth-thankyou&goodbye)
exten => s,n,Macro(hangupcall,)

As it stands just now it will loop for a second then ring out to the original extensions VM but I would prefer the forward attempt to fail in the firsplace due to a loop condition.

I’m using FreePBX ( ) Asterisk 1.8


I have found the below script (which I have tried) but I can’t get it to work. It seems to reference TL a lot and I have changed this to suit my set up but still no joy. I’m starting to think this script is for something completly different.

Any advice greatly appreciated