Hi All,
Trying to modify a great script created awhile ago by community member lgaetz (I cant post a link to the post since I’m a new user, sorry!) to prevent spam and robocallers.
Brand new to custom Asterisk dialplans, so I apologize in advance if the code is messy. I’m having issues trying to conceptualize how to manipulate/read one of the variables generated by a random generator to control the call flow. Here’s what I have so far:
[bender-blocker]
exten => s,1,Noop(Entering context bender-blocker in extensions_custom.conf)
exten => s,n,Answer
exten => s,n,Set(count=0)
exten => s,n(restart),Set(goal=${RAND(0,9)}) ; generates a random number, modify as req'd
exten => s,n,ExecIf($["${goal}"="1"]?SayDigits(1)) ; will assign discrete Playback() files later that I recorded
exten => s,n,ExecIf($["${goal}"="2"]?SayDigits(2))
exten => s,n,ExecIf($["${goal}"="3"]?SayDigits(3))
exten => s,n,ExecIf($["${goal}"="4"]?SayDigits(4))
exten => s,n,ExecIf($["${goal}"="5"]?SayDigits(5))
exten => s,n,ExecIf($["${goal}"="6"]?SayDigits(6))
exten => s,n,ExecIf($["${goal}"="7"]?SayDigits(7))
exten => s,n,ExecIf($["${goal}"="8"]?SayDigits(8))
exten => s,n,ExecIf($["${goal}"="9"]?SayDigits(9))
exten => s,n,ExecIf($["${goal}"="0"]?SayDigits(0))
exten => WaitExten()
exten => ${goal},n,Return ; conceptually would like to use ${goal} variable to control which is a valid extension and return it to the FPBX call flow
exten => i,1,Playback(invalid_option)
exten => i,n,Goto(restart)
exten => t,1,Playback(goodbye)
exten => t,n,Hangup()
I am using the WaitExten() application to handle timeouts and if the caller were to press digits while a recording is being played.
Thanks in advance!