Запрос ЦеныЗапрос Цены
Онлайн ЧатОнлайн Чат
Зона КлиентовЗона Клиентов
КонтактыКонтакты
Скрыть
Live Support
Sales department
Technical Support
The procedure of blocking by common patterns with FreePBX and asterisk

Highlights :

What we want to achieve: to block all calls from mobile phone of a local operator, also each time our DIDs are called from this telco.network we need to send a notification about it by mail.

What we have on our PBX : Asterisk 1.6.2.X and FreePBX 2.8 installed with core modules; while searching through web and asterisk modules , we found only one related module , that is Blacklist module , but it does not support call blocking by CallerID patterns , in this case it would be necessary to add each number individually, it will be a big list and to make this list it takes a huge amount of time.

What we did : We decided to perform a modification of Blacklist module at Asterisk level , basically we were using its ability (module logic) to run into context that is executed before all the other on incoming calls in [app-blacklist-check]. We modified just this context without any alteration at web scripts level, so it could be easily removed or modified in case such a necessity occurs.

How it works : we fully re-wrote the context [app-blacklist-check] . What we added is basically check of CallerID , in case CallerID matched our pattern , we proceeded on calling a script which would send a notification message regarding who has been called at which time and which DID has been called.

Step by step :

  • The first step to undertake, when we are dealing with an incoming call [app-blacklist-check] is to get the call and check if this Caller ID matches the pattern, even if it does, we need to look over the predetermined allowed list of calls, because we may have some exception going on.
  • In order to inspect the above-mentioned situation, we may deliver ourselves of a simple script /root/bin/did_test.sh, which returns 1 in case the CallerID is NOT available in the list and should be blocked, or 0 in any other cases. In case this Caller ID must be blocked, we will carry out the procedure as follows: we’ll jump to n (Blacklist) priority, at this point the script /root/bin/send_block_notify. will be executed which will result in generating a notification message informing about what DID was blocked, about the caller ID and the date of the call.
  • Further the Zapateller application will come into action, the purpose of which is to block the telemarketers by delivering a special sound called Special Information Tone(SIT). In our case, it is used for notification purpose that the call has not been accepted.
  • To rewrite asterisk part of a module you need to place full content of context in the /etc/asterisk/extensions_override_freepbx.conf file. The following example will block all the calls that match the following pattern _3737[89]XXXXXX. In case you need to block more patterns you are advised to add the same extensions for each pattern you wish to check.

 


exten => s/_3737[89]XXXXXX,1,Answer()                                                                                           
exten => s/_3737[89]XXXXXX,n,Wait(1)                                                                                            
;
;Checking for DID if we should to check it or not
;
exten => s/_3737[89]XXXXXX,n,Set(result=${SHELL(/root/bin/did_test.sh ${CALLERID(dnid)} ${CALLERID(num)} ) }  )
;
;Check if we should block it.
;
exten => s/_3737[89]XXXXXX,n,GotoIf($["${result}" = "1"]?blacklist)                                                             
exten => s/_3737[89]XXXXXX,n(noblock),Return()                                                                                  
;
;block caller ID
;
exten => s/_3737[89]XXXXXX,n(blacklist),System(/root/bin/send_block_notify.sh support@example.com ${CALLERID(dnid)} ${CALLERID(num)})  
;
;Coment this link if you don't want any of your calls to be blocked.
;
exten => s/_3737[89]XXXXXX,n,Zapateller()                                                                            
exten => s/_3737[89]XXXXXX,n,Playback(ss-noservice)                                                                             
exten => s/_3737[89]XXXXXX,n,Hangup

 

  • An example comes in handy about how the script /root/bin/send_block_notify.sh, that is meant to send a notification about did, will receive three arguments: the first is the email address on which the notification is intended to be sent; second is ${CALLERID(dnid)} – its variability allows us to view the dialed number and, finally, ${CALLERID(num)}) which is the caller ID itself .

In conclusion : I dare say that FreePBX is a very powerful and extremely customizable product, even if we are not bothering to write a new module, we can easily change a module with a similar functionality to insure the expected behavior, all the actions were performed on asterisk level without any knowledge of module programming and structure.

Запросить цену
Заполните форму и мы свяжемся с Вами в ближайшее время
Вход для клиентов
Система запросов и другие полезные сервисы для наших клиентов
Свяжитесь с нами
Мы с удовольствием ответим на все ваши вопросы