Gotoif question

Please, can someone explain to me, why i always get the beep sound in every case?

exten=>s,1,Answer
exten=>s,2,GotoIf($[${CALLERID(num) = “0063994021”]?yes)
exten=>s,3,GotoIf($[${CALLERID(num) != “0063994021”]?no)
exten=>s,n(yes),Playback(beep)
exten => s,n,Dial(SIP/1140,20,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup
exten=>s,n(no),Playback(test1)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup

HI
Plz check following Gotoif settings that may help you

GotoIf($[(${CALLERID(num)}) = 4]?yes:no)
use such settings. ithink ur mising one of } barcket

try this

Amit

You need to close the curly brace for CALLERID. You should watch the console while placing these calls and the output can give you clues. What’s happening is that apparently the GotoIf statement is just being ignored because of the incorrect syntax.

Do this:

exten=>s,2,GotoIf($[${CALLERID(num)} = "0063994021"]?yes)

You can skip the second test completely by doing it this way:


exten=>s,2,GotoIf($[${CALLERID(num)} = "0063994021"]?yes:no) 

yes i correct my brackets, and when i try this i always have a “no” desicion!

:unamused:

Remove the quotes from around the number.

exten=>s,2,GotoIf($[${CALLERID(num)} = 0063994021]?yes)

Then perhaps you need to stick in a NoOp to print out the caller ID string.

Also, you are mixing numbers and the n. It is best if you stick with one or the other.

exten=>s,1,Answer
exten=>s,n,NoOp(--------------------------${CALLERIS(num)})
exten=>s,n,GotoIf($[${CALLERID(num) = “0063994021”]?yes)
exten=>s,n,GotoIf($[${CALLERID(num) != “0063994021”]?no)
exten=>s,n(yes),Playback(beep)
exten => s,n,Dial(SIP/1140,20,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup
exten=>s,n(no),Playback(test1)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup

I heard beep message in every case!

Please capture and paste the console output after placing one of these calls. Be sure that verbosity is set to at least 3.

This is my asterisk code in extension.conf:

[zovu1140]
exten=>s,1,Answer
exten=>s,n,NoOp(--------------------------${CALLERIS(num)})
exten=>s,n,GotoIf($[${CALLERID(num)} = “0063994021”]?12345:12344)
exten=>s,12345,Playback(conf-userwilljoin)
exten => s,n,Dial(SIP/1140,20,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup
exten=>s,12344,Playback(hello-world)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup

This is output on CLI:

1 CASE

– Accepting call from ‘063994021’ to ‘835640’ on channel 0/1, span 1
– Executing [835640@from-pstn:1] NoOp(“Zap/1-1”, “”) in new stack
– Executing [835640@from-pstn:2] Set(“Zap/1-1”, “CALLERID(num)=0063994021”) in new stack
– Executing [835640@from-pstn:3] Goto(“Zap/1-1”, “zovu1140|s|1”) in new stack
– Goto (zovu1140,s,1)
– Executing [s@zovu1140:1] Answer(“Zap/1-1”, “”) in new stack
[Jan 18 17:32:14] ERROR[32070]: pbx.c:1523 ast_func_read: Function CALLERIS not registered
– Executing [s@zovu1140:2] NoOp(“Zap/1-1”, “--------------------------”) in new stack
– Executing [s@zovu1140:3] GotoIf(“Zap/1-1”, “0?12345:12344”) in new stack
– Goto (zovu1140,s,12344)
– Executing [s@zovu1140:12344] Playback(“Zap/1-1”, “hello-world”) in new stack
– <Zap/1-1> Playing ‘hello-world’ (language ‘en’)
– Executing [s@zovu1140:12345] Playback(“Zap/1-1”, “conf-userwilljoin”) in new stack
– <Zap/1-1> Playing ‘conf-userwilljoin’ (language ‘en’)
– Channel 0/1, span 1 got hangup request
== Spawn extension (zovu1140, s, 12345) exited non-zero on ‘Zap/1-1’
– Hungup ‘Zap/1-1’

2 CASE

– Accepting call from ‘000385912386057’ to ‘835640’ on channel 0/1, span 1
– Executing [835640@from-pstn:1] NoOp(“Zap/1-1”, “”) in new stack
– Executing [835640@from-pstn:2] Set(“Zap/1-1”, “CALLERID(num)=000385912386057”) in new stack
– Executing [835640@from-pstn:3] Goto(“Zap/1-1”, “zovu1140|s|1”) in new stack
– Goto (zovu1140,s,1)
– Executing [s@zovu1140:1] Answer(“Zap/1-1”, “”) in new stack
[Jan 18 17:33:27] ERROR[32084]: pbx.c:1523 ast_func_read: Function CALLERIS not registered
– Executing [s@zovu1140:2] NoOp(“Zap/1-1”, “--------------------------”) in new stack
– Executing [s@zovu1140:3] GotoIf(“Zap/1-1”, “0?12345:12344”) in new stack
– Goto (zovu1140,s,12344)
– Executing [s@zovu1140:12344] Playback(“Zap/1-1”, “hello-world”) in new stack
– <Zap/1-1> Playing ‘hello-world’ (language ‘en’)
– Executing [s@zovu1140:12345] Playback(“Zap/1-1”, “conf-userwilljoin”) in new stack
– <Zap/1-1> Playing ‘conf-userwilljoin’ (language ‘en’)
– Executing [s@zovu1140:12346] Dial(“Zap/1-1”, “SIP/1140|20|T”) in new stack
– Called 1140
– SIP/1140-0a0b2188 is ringing
– Channel 0/1, span 1 got hangup request
== Spawn extension (zovu1140, s, 12346) exited non-zero on ‘Zap/1-1’
– Hungup ‘Zap/1-1’
[/b]

Jan 18 17:32:14] ERROR[32070]: pbx.c:1523 ast_func_read: Function CALLERIS not registered
– Executing [s@zovu1140:2] NoOp(“Zap/1-1”, “--------------------------”) in new stack

You cust and pasted a mistake on my part. Change CALLERIS it CALLERID and you shoud see the caller ID number after the dashes when you get a call.

Here is the line to fix:

exten=>s,n,NoOp(--------------------------${CALLERID(num)})

I’m in confuse. I don’t now what is the problem. This is the stupid situation but i always have a first choice, never second choice.
On CLI interface i don’t have any errors.

xten=>s,1,Answer
exten=>s,n,NoOp(--------------------------${CALLERID(num)})
exten=>s,n,GotoIf($[${CALLERID(num) = “0063994021”}]?yes)
exten=>s,n,GotoIf($[${CALLERID(num) != “0063994021”}]?no)
exten=>s,n(yes),Playback(conf-userwilljoin)
exten => s,n,Dial(SIP/1140,20,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup
exten=>s,n(no),Playback(hello-world)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup

I’m using this and it works perfectly well:

Incoming calls from PSTN
[incoming]
exten => s,1,NoOP(Time=${STRFTIME(${EPOCH},%H)}.${STRFTIME(${EPOCH},%M)})
exten => s,n,NoOP(${CALLERID(all)})
exten => s,n,GotoIf($[${CALLERID(num)}=Unknown]?default,unknown,1) ;Unknown number
exten => s,n,GotoIf($["${CALLERID(name)}"=“anonymous”]?default,unknown,1) ;Anonymous number
exten => s,n,GotoIf($[${CALLERID(num)}=0?default,unknown,1) ;0 number
exten => s,n,GotoIf($[${CALLERID(num)}=4732893xxx]?default,1210,1)
exten => s,n,GotoIf($[${CALLERID(num)}=32476378xxx]?henk_gsm_disa,s,1)
exten => s,n,GotoIf($[${CALLERID(num)}=32476378xxx]?default,1000,1)

I have the same problem with GOTOIF!

But I have NO problem with it. :smiley:
What I gave you works well. (with me)

Now that you have the NoOp fixed, what does the console output look lke when you get a call? Now you can see what you are getting as far as callerid info goes.

Console output gives me aerror CALLERID(all), and i see when i capture CALLERID, i see gotoif when compare the number, but always i have the first choice.

I took a closer look at your goto if, and I took a look at one of mine that works.

Two things came up, one is I use a bit more whitespace and I do not quote the string. Second is I handle both the true and the false condition in the same statement.

Here is mine:

exten =>444,n,GotoIf($[ ${count} = 3 ]?hang:repeat)

Can you try this:

exten=>s,n,GotoIf($[${CALLERID(num) = 0063994021}]?yes:no)

I am not sure if the = is a string match or an arithmatic match.

It is also odd that the callerid in the NoOp does not work for you. Pasting the console output is helpful.

Thanks everybody dear friends on helping. Now this is the right procedure. Now everthing works very fine.

exten => s,1,Answer
exten => s,2,NoOp(---------------------------------------${CALLERID(num)})
exten => s,3,GotoIf($["${CALLERID(num)}" = “0063994021”]?1000)
exten => s,4,GotoIf($["${CALLERID(num)}" = “0063156434”]?1000)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},2)
exten => s-NOANSWER,1,Dial(SIP/1141,40,T) ;*
exten => s-CONGESTION,1,Dial(SIP/1141,40,T) ;*
exten => s-CANCEL,1,Hangup ;*
exten => s-BUSY,1,Dial(SIP/1141,40,T) ;*
exten => s,n,NoOp( Dial Status: ${DIALSTATUS}) ;*
exten => s,n,Goto(s-${DIALSTATUS},2) ;*
exten => s-NOANSWER,2,Dial(SIP/1100,40,T)
exten => s-CONGESTION,2,Dial(SIP/1100,40,T)
exten => s-CANCEL,2,Hangup
exten => s-BUSY,2,Dial(SIP/1100,40,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup
exten => s,1000,Background(vm-theperson)
exten => s,n,Dial(SIP/1140,20,T)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},2)
exten => s-NOANSWER,1,Dial(SIP/1141,40,T) ;*
exten => s-CONGESTION,1,Dial(SIP/1141,40,T) ;*
exten => s-CANCEL,1,Hangup ;*
exten => s-BUSY,1,Dial(SIP/1141,40,T) ;*
exten => s,n,NoOp( Dial Status: ${DIALSTATUS}) ;*
exten => s,n,Goto(s-${DIALSTATUS},2) ;*
exten => s-NOANSWER,2,Dial(SIP/1100,40,T)
exten => s-CONGESTION,2,Dial(SIP/1100,40,T)
exten => s-CANCEL,2,Hangup
exten => s-BUSY,2,Dial(SIP/1100,40,T)
exten => s-CHANUNAVAIL,1,SetCallerId(${CALLERIDNUM})
exten => s-CHANUNAVAIL,2,Dial(SIP/sippeer/${LOCALAREACODE}${ARG1},T)
exten => s,n,Hangup

The post above this one may work for someone, but not for me and probably not for a lot of folks.

I have tried just about every combination I can think of and [color=red]GotoIf[/color] with [color=red]${CALLERID(num)}[/color] either does not work or is just plain poorly documented. It ALWAYS executes the first option and never the second (failure) option.

Perhaps one of the reasons there are so many differing answers to the primary question in this thread is everyone is using a different disty of asterisk. My question is specific to 1.4.17:

What is the correct syntax for a GotoIf evaluation of ${CALLERID(num)} for 1.4.17 such that if ${CALLERID(num)} is equal to the inbound CallerID execution falls to “x” else execution falls to “y”?

Oh, and here is some of the bad code I have tried:

exten => s,1,NoOp(Caller id is “${CALLERID(num)}”)

exten => s,3,GotoIf($["${CALLERID(num)}" = “9996661234”]?100)
exten => s,4,GotoIf($["${CALLERID(num)}" != “9996661234”]?999)

;exten => s,1,NoOP(------------"${CALLERID(num)}")
;exten => s,1,NoOp(------------${CALLERID(num)})

;exten=>s,2,GotoIf($[${CALLERID(num)} = “9996661234”]?yes:no)
;exten => s,2,GotoIf($[${CALLERID(num) = 9996661234}]?yes:no)
;exten => s,3,GotoIf($[${CALLERID(num) != 9996661234}]?no)
;exten => s,2,GotoIf($["${CALLERID(num)}" = “9996661234”]?yes:no)
;exten => s,2,GotoIf($[${CALLERID(num)}=9996661234]?no:yes)
;exten => s,2,GotoIf($[${CALLERID(num)}=9996661234]?yes:no)
;exten => s,2,GotoIf($[${CALLERID(num)}=9996661234]?yes,no)
;exten => s,2,GotoIf($[${CALLERID(num)}=9996661234]?no,yes)

Just one simple example I, and others, could build off would be greatly appreciated.

Regards,

Ike

to be sure of any syntax on any fuinction/application in asterisk use console command under CLI core show application/function “NameMe”

so in you case, core show application gotoif