7

I wrote simple dial plan in asterisk. This dial-plan target is to check caller-id of incoming call and for specific hangup :) !

but this dial-plan hangup all incoming call with diffrent caller-id.
So what do i do? ;(

   [general]  
    static=yes  
    writeprotect=yes  
    autofallthrough=yes  
    clearglobalvars=no  
    priorityjumping=yes  
    include "exten_gvars.inc"  

    [macro-queue]
    exten => s, 1, Queue(${ARG1})

    [default]  
    exten => s, 1, Answer  
    exten => s/9999, 2 ,Hangup  
    exten => s, 2, BackGround(welcome)  
    exten => s, 3, Macro(queue,operator)  

Edit

i change my dial plan to this but it not working, incoming call hangup after two beep(i know it occur cuz a mistake in my dial plan)!

    [general]
static=yes
writeprotect=yes
autofallthrough=yes
clearglobalvars=no
priorityjumping=yes
#include "exten_gvars.inc"

[macro-monitor]
exten => s, 1, MixMonitor(${UNIQUEID}.wav)
exten => s, 2, SetCIDName(${UNIQUEID}#${CALLERIDNAME},a)

[macro-defaultLine]
exten => s, 1, Macro(monitor)
exten => s, 2, Dial(SIP/${ARG1},60,T)

[macro-queue]
exten => s, 1, Macro(monitor)
exten => s, 2, Queue(${ARG1})

[inbound]
exten => _XX, 1, Macro(defaultLine,${EXTEN})

[default]
exten => 123,1,GotoIf($[${CALLERID(num)} = XX]?reject:allow)
exten => 123,n(allow),Answer
exten => 123,n,BackGround(welcome)
exten => 123,n,Macro(queue,operator)
exten => 123,n(reject),BackGround(WTF)
exten => 123,n,Hangup()
include => inbound
Rev
  • 2,269
  • 8
  • 45
  • 75
  • so let me make this question harder !!!! I Want if 9999 call, first hear a sound file and then hangup. – Rev Sep 02 '10 at 08:37
  • Please phrase your question as something better than "So what do i do?" If this isn't a programming question, perhaps http://superuser.com is a better venue. – Gabe Sep 02 '10 at 08:39

4 Answers4

13

Here is your anti ex-girlfriend Dailplan, assuming xxxxx is your ex-girlfriends number

exten => 123,1,GotoIf($[${CALLERID(num)} = xxxxx]?reject:allow)
exten => 123,n(allow),Dial(Zap/4)
exten => 123,n,Hangup()
exten => 123,n(reject),Playback(abandon-all-hope)
exten => 123,n,Hangup()

Hope this helps you

Shrikant Soni
  • 2,337
  • 2
  • 30
  • 35
  • 2
    How this answer got so many upvotes is beyond me. I see this kind of dialplan all the time. Guys,what happens when you have 2 ex-girlfriends? or 50 ? How many times did you need to screen for 1 single number. Most often it is a list of numbers and list of prefixes. The GotoIf will not work. Use the dialplan as it was intended, or move to an AGI script if you feel like programming. – Radu094 Sep 16 '10 at 08:58
3

You do not have a step 2 for other callerids and autofalltrhough is enabled, which means (in 1.6) that the call will be dropped after step 1.

[default]
exten => s, 1, Answer
exten => s/9999, 2 ,Hangup
exten => s, 2, NoOp  
exten => s, 3, BackGround(welcome)
exten => s, 4, Macro(queue,operator) 

Edit: Are you sure the callerID is EXACTELLY 9999? Try replacing that line with

exten => s, 2, NoOp((${CALLERID(all)})

then look in the console and see what the callerID is.

use:

 asterisk -r 

then enter:

 core set verbose 5

also, enter:

show dialplan

and see if the dialplan is correctly loaded into asterisk

Radu094
  • 28,068
  • 16
  • 63
  • 80
  • I change my dial plan as like you said. but now for 9999 number call didn't hangup and all call same as as 9999 number, go to background step. – Rev Sep 02 '10 at 08:34
  • thanks but is there any solution for see caller id for incoming call or online calls. i check my voip gateway and see number, and input that number in my dial plan. thanks for your attention – Rev Sep 15 '10 at 11:28
  • The NoOp(${CallerID(all)}) will display the caller id on the asterisk console when that step is executed. – Radu094 Sep 16 '10 at 09:00
0

First of all, it would appear that you don't really understand how the Asterisk dialplan works. The code block you put up there is just plain wrong, Asterisk won't complain - as dialplan isn't supposed to do so.

Let's examine one by one:

[macro-queue]
exten => s, 1, Queue(${ARG1})

[default]  
exten => s, 1, Answer  
exten => s/9999, 2 ,Hangup  
exten => s, 2, BackGround(welcome)  
exten => s, 3, Macro(queue,operator)  

The reason the above is wrong is due to the fact that you can't put a CALLERID matching on a single line of the extension - it's should be all the way. So technically, you would need:

[macro-queue]
exten => s, 1, Queue(${ARG1})

[default]  
exten => s/9999, 1, Answer  
exten => s/9999, 2 ,Hangup  
exten => s/9999, 2, BackGround(welcome)  
exten => s/9999, 3, Hangup 

exten => s, 1, Answer  
exten => s, 2 ,Hangup  
exten => s, 2, BackGround(welcome)  
exten => s, 3, Macro(queue,operator)  

Now, that isn't a proper way of doing this - simply because you'll be replicating lines over and over again. The right way of doing it is very much similar to the previous answer, however, this is what I would do:

exten => s, 1, Answer
exten => s, n, Gotoif($["${CALLERID(num)}" = "9999"]?reject:continue)
exten => s, n(continue), Background(Welcome)
exten => s, n, Macro(queue, operator)
exten => s, n(reject), Hangup()

Now, you can extend the various CALLERID numbers you want to block. Again, assuming this is the result you were looking to achieve.

0

It's quite simple:

[default]  
    exten => s/9999,1,Hangup  

    exten => s,1,Answer  
    exten => s,2,BackGround(welcome)  
    exten => s,3,Macro(queue,operator)