# Blacklist numbers for outbound calling

Hi,

I’m trying to Add numbers in Blacklist so that whenever someone tries to call that number, it doesn’t allow it

I’ve tried the following but doesn’t work

`exten => s,1,GotoIf(\${DB_EXISTS(BLACKLIST/\${EXTEN})}?banned,s,1)`

``````[banned]
exten => s,1,Playback(silence/2&im-sorry)
exten => s,n,Playback(cannot-complete-as-dialed)
exten => s,n,Playback(privacy-you-are-blacklisted)
exten => s,n,Playback(goodbye)
exten => s,n,Hangup()
``````

have inserted the number in blacklist using

`database put blacklist 12345678900 "Blacklisted for testing"`

You should use \$[]? and you are using \${}? Curly brackets are for variables.

oh okay…I’ll try that

Can you please be more precise where I should use \$[]? Because in all examples I’ve gone through uses \${}

Also curly brackets { } are general repetition quantifiers. They specify a minimum and maximum number of permitted matches. And here I’m matching ‘DB_EXISTS’ and ‘EXTEN’

in dialplan
exten => _XXXX.,n,Macro(blacklist,\${EXTEN})

[macro-blacklist]
exten => s,1,GotoIf(\${DB_EXISTS(blacklist/\${ARG1})}?banned)

[banned]
exten => s,1,Playback(silence/2&im-sorry)
exten => s,n,Hangup()

1 Like

Expressions are combinations of variables, operators, and values that you string together to produce a result. An expression can test values, alter strings, or perform mathematical calculations.

Everything contained inside a bracket pair prefixed by a \$ (like \$[this]) is considered as an expression and it is evaluated.

https://wiki.asterisk.org/wiki/display/AST/Expressions

http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/asterisk-CHP-6-SECT-1.html

Your extension ‘s’ won’t match 12345678900.

Your extension would have to be 12345678900.

It is going to [banned] when ever someone dials a number in blacklist…it is matching the number in blacklist

1 Like

He is using macro, The macro works only using the s extension, he passing the number to check using the macro argument so it will works fine

I didn’t see his later post where he had a Macro, in his initial post he was using \${EXTEN} in a ‘s’ extension which would have had the value of ‘s’.