I’m trying to implement this dialplan to block any incoming call without caller ID.
But its always falling to false statement. I can’t figure out, can someone help me
Many thanks
sathees
exten => 441234567890,1,NoOp(From => ${CALLERID(num)} to => ${EXTEN})
same => n,GotoIf($["${CALLERID(num)}" = “”]?not,1:ok,1)
same => n,GotoIf($["${CALLERID(num)}" = “anonymous”]?not,1:ok,1)
same => n,GotoIf($["${CALLERID(num)}" = “unknown”]?not,1:ok,1)
same => n,GotoIf($["${CALLERID(num)}" = “private”]?not,1:ok,1)
same => n,GotoIf($["${CALLERID(num)}" = “unavailable”]?not,1:ok,1)
same => n,Hangup()
exten => not,1,NoOp(without caller ID)
same => n,Answer(500)
same => n,Playback(/usr/src/no-cid)
same => n,Wait(1.5)
same => n,Hangup()
exten => ok,1,NoOp(with caller ID)
same => n,PLayBack(en_GB/press-1)
same => n,PlayBack(en_GB/for-tech-support)
same => n,Dial(PJSIP/100)
same => n,Hangup()
There are 2 distinct variables in Asterisk that make up the information you see on a caller ID screen. CALLERID(number) is the phone number and CALLERID(name) is the name associated with the phone number. Blocking (dropping) calls with no caller ID name is generally not a good idea because of the way caller IDs are attached to a call. The provider takes the phone number and references a database that should have a Caller ID name associated with it. The database lookup is not a high priority and if there is a lot of traffic a legitimate call can go through with no caller ID name, but if you want to do it, it is fairly easy. Placing all the items you want to block in the dialplan is not a good practice. You will end up with a mess as you add more and more items. Asterisk has built in database (ASTDB) to handle tasks like this. You enter the caller IDs you want to block using this format from the Asterisk command line. I believe caller ID names are case sensitive so anonymous would not be a match for ANONYMOUS
database put cidname anonymous 1
database put cidname unknown 1
…and put in the rest.
This puts the caller ID names you want to block in category (called a family) of cidname. Explaining the database is too involved to do here but O’reilly has a good book on Asterisk that explains it… After you have your entries done all you need is one line to test the database for the value of CALLERID(name) that has come in with the call and then send the call where you want.
This line would check the cidname family in the ASTDB and if there was a match send control to the label “not”
A CALLERID(name) with no characters has a length of 0, so you could trap it by testing for a CALLERID(name) that has 0 length. You could do it all in one line, but nested braces and brackets are confusing enough without having a line with a dozen of them. Breaking it up into2 lines, first you set a variable to the length of the CALLERID(name). We will call the variable “cidlen”.
same => n,Set(cidlen=${LEN(${CALLERID(name)})})
Then you compare the variable to 0. If it is 0 you send it to the “not” label. If the variable is not zero the next line in the dialplan would be executed.
Thanks for the help
This DID/DDI number just for tech support only, we don’t want to accept any unwanted call to this number expect our customer.
like David551 mentioned I changed the Dial plan. its work
I will try to implement the Dial Plan pilo2 mentioned.
Regards
Sathees
This is working Dial plan.
exten => 441234567890,1,NoOp(From => ${CALLERID(num)} to => ${EXTEN})
same => n,GotoIf($["${CALLERID(num)}" = “”]?not,1)
same => n,GotoIf($["${CALLERID(num)}" = “anonymous”]?not,1)
same => n,GotoIf($["${CALLERID(num)}" = “unknown”]?not,1)
same => n,GotoIf($["${CALLERID(num)}" = “private”]?not,1)
same => n,GotoIf($["${CALLERID(num)}" = “unavailable”]?not,1)
same => n,Dial(PJSIP/100)
same => n,Hangup()
exten => not,1,NoOp(without caller ID)
same => n,Answer(500)
same => n,Playback(/usr/src/no-cid)
same => n,Wait(1.5)
same => n,Hangup()
If you know the Caller ID of the callers you wish to allow through it might be easier to whitelist them and then blacklist everyone else.
exten => 7124/_480NXXXXXX,1,Goto(RING)
exten => 7124/_520NXXXXXX,1,Goto(RING)
exten => 7124/_602NXXXXXX,1,Goto(RING)
exten => 7124/_623NXXXXXX,1,Goto(RING)
exten => 7124/_928NXXXXXX,1,Goto(RING)
exten => 7124/Anonymous,1,Goto(RING)
exten => 7124,1,NoOP()
same => n,Ringing()
same => n,Wait(16)
same => n,Voicemail(7124,u)
same => n,Hangup()
same => n(RING),Dial(SIP/7124)
Here is an example I use,
I permit callers from my states area codes through to my extension (and Anonymous calls because I need those too) all other callers drop through to Voicemail.