Actions

How to Setup Filters

Revision as of 11:35, 20 March 2020 by Luc Morissette (talk | contribs) (Added new link to routing number script)

Filter Scripts are routing scripts that can be added to any other script. It modifies the behavior of the main script. For example, it can do a remapping of the incoming called number to make it uniform (i.e. Remove the international code). It can also make sure there is no loop (do not route the call back to the incoming Network).

While filters can edit call attributes, they do it once for all matching routes.

Note: If you need to manipulate call attributes per matching route (providing different values for different matching routes), you should instead use route_remap.

Setting up Filter Scripts

To setup a Filter, the main script needs to be modified. The main script can be either simple_routing.rb, or any other script.
First, make sure scripts are enabled for this system:

Gateway
use Script -> Example Scripts  (If none are available, go to the second step, then come back here to chose the script group)

Second, go to the routing script section of the Web portal

Gateway -> Routes -> Routing scripts -> Example Scripts -> simple_routing.rb [Edit]


Three things need to be added. At the start of the script:

require '[filter_ruby_filename]'

In the main class:

include [module_name]

and

before_filter :method => :[method_name]

or

after_filter :method => :[method_name]


For example, the priority_and_weight_load_balancer.rb script would require this to be added to the main script:

require 'priority_and_weight_load_balancer'

class MyMainRoutingClass < BaseRouting
  include PriorityAndWeightLoadBalancer

  after_filter :method => :filter_by_priority_and_weight,

To find the module_name and method, you need to look in the routing script itself:

Gateway -> Routes -> Routing Scripts -> Filters Scripts -> priority_and_weight_load_balancer.rb [Edit]

Then look for the <Module> tag and the <def> tag for the main class

Filter Scripts examples:

  • Request-URI routing (called_pre_remap_and_ruri.rb): Will route the call on SIP RURI instead of the to: field
  • Modify the Nature of Address (noa_npi_remap.rb): We can use this to change the NOA to national or international
  • Remove Loop (FilterRemoveLoop.rb): Will prevent calls from being routed back to the sender
  • Load sharing on NAP groups or on route groups (priority_and_weight_load_balancer.rb): This is script is now installed by default on the systems.
    See Adding Priority and Load Sharing to Routing Script
  • Black and White listing (black_white_listing.rb): With this script, any called or calling number prefix can be blacklisted or whitelisted. This script can be assigned globally, or per NAP. It reads a file which has the called and calling number list.
    See Adding White or Black listing to Routing Script
  • Capture dtmf input (capture_dtmf.rb): With this script, if the called number is a specific value, it will play an announcement and waits to capture digits used for routing.
    See Adding capture dtmf script to Routing Script
  • Route on Called and make call with Routing Number (r_n_cdr.rb): With this script, the called number will be used to route the call, but the call will be made with the routing number.
    See Adding Routing Number script to Routing Script


One example is the Label Routing. Check here: Adding Label Routing to any Routing Script

These filters can be merged in the same routing script. Please contact support for more details.