Beruflich Dokumente
Kultur Dokumente
Contents [hide]
1 Introduction
2 Script routing class
3 What I need to define a script routing class
3.1 'route_order' method
3.2 'route_match' method
3.2.1 :call_field_name
3.2.2 :route_field_name
3.2.3 :proc
3.2.4 :method
3.2.5 base_routing pre-implemented matching method
3.3 'route_remap' method
3.3.1 :call_field_name
3.3.2 :route_field_name
3.3.3 :proc
3.3.4 :method
3.4 'init_routes' method
3.5 'route' method
4 Route retry algorithm
5 What else?
5.1 Examples and tutorials
6 Useful links
Introduction
Working with scripts requires you to define a class that will help you select one
of your previously created routes. There are 3 mandatory things to define for your
script to work:
Define your new script routing class, which can contain one or many of these
methods (route_order,route_match,route_remap)
The 'init_routes' method
The 'route' method
For more information about the parameters that can be used within a method, please
see the mini development guide
route_order
route_match
route_remap
Please note that 'route_order' will be called before 'route_match', both of which
will be called before 'route_remap'.
'route_order' method
'route_order' allows to order routes using one of 3 possible arguments. It is only
possible to call 'route_order' once.
:route_field_name - The field name of the route to order with. The value of the
route field should be an integer so that it can be compared.
:proc - A user-supplied proc to call instead of trying to order internally. It
should accept two arguments (route list, nap list) and return the sorted route
list.
:method - A user-supplied method to call instead of trying to order internally. It
should accept two arguments (route list, nap list) and return the sorted route
list.
base_routing pre-implemented ordering method:
'order_by_asr', this method will order the routes according to the ASR (answer
seizure ratio). This method requires adding a custom NAP parameter called
':asr_type'. Its value can be: global, last_24h, current_hour, last_hour. It can be
used in your custom class like this:
route_order :method => :order_by_asr
'route_match' method
'route_match' allows to match a call to one route using one of 4 possible
arguments. It is possible to call 'route_match' multiple times to reduce the number
of matching routes. Since 'route_match' will return the first matching route it
find, there is a possibility that there is more than one route match, therefore it
is important to order the routes or prioritize them using 'route_order'.
:call_field_name
This option will compare the specified call attribute with the route attribute. For
example, :call_field_name => :called will match the called number attribute.
:proc
A user-supplied proc to call instead of trying to do the match internally. It
should accept three arguments (route, call, nap list) and return a boolean to
indicate the match
:method
A user-supplied method to call instead of trying to do the match internally. It
should accept three arguments (route, call, nap list) and return a boolean to
indicate the match
'route_remap' method
'route_remap' allows to remap the parameter of the route or the call using one of
the 4 possible arguments. There are actually 3 types of remapping that can be
performed: via the :call_field_name/:route_field_name arguments; the :proc
argument; and/or the :method argument.
:call_field_name
The field name of the call to remap
:route_field_name
The field name of the route to remap with. The default is to use the call field
name. If the value of the field is empty, the incoming call's attribute is used.
The value of the route field can be a regular expression remap. (e.g.,
/(555000.)/001\1/ )
:proc
A user supplied proc to call instead of trying to do the remap internally. It
should accept four arguments (route, call object, nap list, call params) and return
a hash of remapped fields
:method
A user supplied method to call instead of trying to do the match internally. It
should accept four arguments (route, call object, nap list, call params) and return
a hash of remapped fields
'init_routes' method
The 'init_routes' is a mandatory method that is call every time the script is
loaded (i.e., think loading the configuration). It may be to your advantage to
perform some pre-processing such as ordering your routes; that way the routes will
not be re-ordered at every call that comes in.
'route' method
The 'route' is a mandatory method that is call at every call that comes in. This is
where you can perform the dynamic routing part.
What else?
There are numerous possibilities:
Useful links
Tmedia Routing