Hello All,
I am using Asterisk 1.8.x.x
Can anyone please help me to understand how to use “GotoIf” to check two conditions at the same time? I tried and it didn’t work. I am trying to check if the “CALLERID” matches predefined numbers and if there is a match then answer the call else reject.
Since it didnt work, I trying it to do by using “GotoIf” twice but even the I get a warning… details below. Why is that I am getting a warning and also how can I use just one “GotoIf” two check if CALLERID matches the two predefined numbers.
WARNING:
[color=#FF0000][xxx xx 08:04:01] WARNING[4070]: ast_expr2.fl:468 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘=’, expecting $end; Input: = 0123456789
[xxx xx 08:04:01] WARNING[4070]: ast_expr2.fl:468 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘=’, expecting $end; Input: = 0987654321[/color]
My code in EXTENSIONS.CONF
[code][globals]
ENABLEDNUM1=0123456789 ; Calls from any number other than this will be rejected
ENABLEDNUM2=0987654321
[incoming]
exten => s,1,NoOp() ; All calls to this context “start” here, Dont do anything
same => n,Verbose(2,Incoming call from ${CALLERID(num)}) ; DEBUG - print callerid
same => n,Verbose(2,Enabled number is ${ENABLEDNUM1}) ; DEBUG - print enabled number
same => n,Verbose(2,Enabled number is ${ENABLEDNUM2}) ; DEBUG - print enabled number
same => n,GotoIf($[${CALLERID(num)} = ${ENABLEDNUM1}]?allow:chktwo) ; Route calls only if from “enabled number” else end call
same => n(chktwo),GotoIf($[${CALLERID(num)} = ${ENABLEDNUM2}]?allow:reject)
same => n(allow),Answer() ; Answer calls only if from enabled number
same => n,Hangup() ; Hangup
;same => n(reject),Playback(vm-goodbye) ; Playback “Good Bye” from location /var/lib/asterisk/sounds/en
same => n(reject),Hangup() ; Ignore calls (goes to VM) from any number other than “${ENABLEDNUM}”[/code]
Any help is really appreciated.
Thanks,
rajjar