Play message based on RDNIS

Ive got the call forwarding working quite nicely based on RDNIS.

Now I am trying to play an announcement before forwarding the call, also based on RDNIS.

I dont have quite the correct syntax. Can someone assist?

Here is my syntax.

[from-ptsn-checkdivert]
exten => _X!,1,Noop(RDNIS=${CALLERID(rdnis)})
;the next three lines, the syntax is not correct
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?Answer())
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?Playback(GreetingAnnouncement))
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?Wait(5))
;below is working fine
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?from-internal,*1234,1)
exten => _X!,n,Goto(from-ptsn,${EXTEN},1)

GotoIf will only send to a label or to context,exten,priortiy which is why the final gotoif line is the only one that works. What you want in the earlier lines is ExecIf

> core show application ExecIf

  -= Info about application 'ExecIf' =-

[Synopsis]
Executes dialplan application, conditionally.

[Description]
If <expr> is true, execute and return the result of <appiftrue(args)>.
If <expr> is true, but <appiftrue> is not found, then the application will
return a non-zero value.

[Syntax]
ExecIf(expression?appiftrue(args)[:appiffalse(args)])

Thank you lgaetz! Your assistance helped me and I got this working.

Here is the correct syntax that works;

[from-ptsn-checkdivert]
exten => _X!,1,Noop(RDNIS=${CALLERID(rdnis)})
;the next three lines, the syntax is now correct
exten => _X!,n,ExecIf($["${CALLERID(rdnis)}" = "2125551212"]?Answer())
exten => _X!,n,ExecIf($["${CALLERID(rdnis)}" = "2125551212"]?Playback(custom/GreetingAnnouncement))
exten => _X!,n,ExecIf($["${CALLERID(rdnis)}" = "2125551212"]?Wait(5))
;below is working fine
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?from-internal,*1234,1)
exten => _X!,n,Goto(from-ptsn,${EXTEN},1)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.