How to match SIP caller's name?

Hi,

how to match SIP caller’s name? I want to have a dialplan rule like:
exten=>123,n, Gotoif($[${CALLERID(name)} = “ivan”]?lb1:lb2)

i.e. when sip user ‘ivan’ calls extension 123, Asterisk will branch to lb1, otherwise to lb2.

Is there any expression can match a string? or what’s right rule to implement the intended dialplan?

thanks in advance,
BRs,

That should work. Try taking out the spaces. Also try using the callerid number.

exten=>123,n, Gotoif($[${CALLERID(num)}=“ivan”]?lb1:lb2)

[quote=“Dovid”]That should work. Try taking out the spaces. Also try using the callerid number.

exten=>123,n, Gotoif($[${CALLERID(num)}=“ivan”]?lb1:lb2)[/quote]

the rule seems not work, it always go to lb2. Not sure what’s wrong.

the following are the rules and log message, any clue?

thanks for help

exten=>444, 1, Answer()
;exten=>444, n, SayAlpha(${CALLERID(name)})
exten=>444, n, Gotoif($[${CALLERID(num)}=“ivan”]?lb1:lb2)
exten=>444, n(lb1), SayDigits(3)
exten=>444, n, Hangup()
exten=>444, n(lb2), SayDigits(4)
exten=>444, n, Hangup()

Executing [444@tutorial:2] GotoIf(“SIP/ivan-0862f490”, “0?lb1:lb2”) in new stack
[/code]

In the number test replace “ivan” with the number that ivan should be calling from.

IE…
exten=>123,n, Gotoif($[${CALLERID(num)}=1234]?lb1:lb2)

Where 1245 is ivan’s extension or cid num.

[quote=“SomeJ”]In the number test replace “ivan” with the number that ivan should be calling from.

IE…
exten=>123,n, Gotoif($[${CALLERID(num)}=1234]?lb1:lb2)

Where 1245 is ivan’s extension or cid num.[/quote]

where to set ivan’s extension or cid num? sip.conf?

${CALLERID(name)} is ‘ivan - SIP’, and ${CALLERID(num)} is ‘ivan’. So, I think the problem can be treated as matching string in expression…

CALLERID(num) should not be set to “ivan”. The CALLERID(num) should be the NUMBER of the caller/callee.

Is ivan a user on your server or someone who is just calling in? If they are a user then you have control of their number via the sip config in the callerid field. But i think we are getting off track with that.

If ivan is an outside caller i would recomend routing based on the callerid number and not the name as the name may not always be reliable.