How to Use Go to If

Guys, I need help…I want to use Goto If in my asterisk configuration, the case is if extension 5101 dial to 5102 and answered by extension 5102 then go to recording context but in 5 second extension 5102 no answered or busy then go to priority 3 or s-${DIALSTATUS}, i create script in below it doesn’t work, What i should do ??

exten => _5XXX,1,Dial(SIP/${EXTEN},5,t)
exten => _5XXX,2,GotoIf($[${EXTEN}=_5XXX]?recording:3)
exten => _5XXX,3,Goto(s-${DIALSTATUS})
exten => _5XXX,4(s-NOANSWER),Playback(followme/status)
exten => _5XXX,5,Goto(from-internal,0,1)
exten => _5XXX,6,Hangup
exten => _5XXX,7(s-BUSY),Goto(ivr-sibuk,s,1)
exten => _5XXX,8,Hangup
exten => _5XXX,9(s-CHANUNAVAIL),Goto(ivr-sibuk,s,1)
exten => _5XXX,10,Hangup
exten => _5XXX,11(s-CONGESTION),Goto(ivr-sibuk,s,1)
exten => _5XXX,12,Hangup
exten => _*8X.,1,Pickup(${EXTEN:2}@voip-trial)

[recording]
exten => _5XXX,1,Macro(Snoop,${EXTEN})
exten => _5XXX,n,Dial(SIP/${EXTEN},${TIMEOUT})
exten => _5XXX,n,StopMixMonitor
exten => _5XXX,n,hangup

This is my output of CLI :
– Executing [5102@voip-trial:1] Dial(“SIP/5101-00000000”, “SIP/5102,5,t”) in new stack
== Using SIP RTP CoS mark 5
– Called 5102
– SIP/5102-00000001 is ringing
– SIP/5102-00000001 answered SIP/5101-00000000
== Spawn extension (voip-trial, 5102, 1) exited non-zero on ‘SIP/5101-00000000’

Thanks for your help…

Extension patterns can’t be used as operands of =. If you want a pattern match here, you should use regular expressions functions. In any case, you have constrained the extension to match _5XXX, altready, at this point.

If you only provide one sub-field in a Goto, it is the priority, not the context.

Priorities 2 and 3 could have been merged.

Priorities 8, 10 and 12 are unreachable.