<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://docs.telcobridges.com/mediawiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://docs.telcobridges.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Routing_script_tutorial%3Aroute_match_Tutorial</id>
		<title>Routing script tutorial:route match Tutorial - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://docs.telcobridges.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Routing_script_tutorial%3Aroute_match_Tutorial"/>
		<link rel="alternate" type="text/html" href="https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;action=history"/>
		<updated>2026-06-10T01:10:39Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.1</generator>

	<entry>
		<id>https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=568&amp;oldid=prev</id>
		<title>10.0.0.157 at 15:45, 20 May 2009</title>
		<link rel="alternate" type="text/html" href="https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=568&amp;oldid=prev"/>
				<updated>2009-05-20T15:45:13Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:45, 20 May 2009&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 182:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 182:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The gateway application queries every second the status and keep it available for routing script (due to the synchronous nature of the status query, it is preferable to have another thread polling the status than querying the status for each call). &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The gateway application queries every second the status and keep it available for routing script (due to the synchronous nature of the status query, it is preferable to have another thread polling the status than querying the status for each call). &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The script uses 2 status available (:asr_statistics_struct_last_24h_asr_percent and :asr_threshold in the naps) in the naps, for a complete list of the status available go [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;knowledgebase&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;toolpack:script_routing&lt;/del&gt;#&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;nap_statuses&lt;/del&gt;|here]] in the NAP_STATS_FIELDS define. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The script uses 2 status available (:asr_statistics_struct_last_24h_asr_percent and :asr_threshold in the naps) in the naps, for a complete list of the status available go [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Routing_script_tutorial&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Mini_Development_Guide&lt;/ins&gt;#&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Nap status&lt;/ins&gt;|here]] in the NAP_STATS_FIELDS define. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you check the NAP_STATS_FIELDS define, you will see that :asr_statistics_struct_last_24h_asr_percent is the combination of 2 field names asr_statistics_struct and last_24h_asr_percent.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you check the NAP_STATS_FIELDS define, you will see that :asr_statistics_struct_last_24h_asr_percent is the combination of 2 field names asr_statistics_struct and last_24h_asr_percent.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:version:1.11a:oldid:561:newid:568 --&gt;
&lt;/table&gt;</summary>
		<author><name>10.0.0.157</name></author>	</entry>

	<entry>
		<id>https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=561&amp;oldid=prev</id>
		<title>10.0.0.157: /* route_match examples */</title>
		<link rel="alternate" type="text/html" href="https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=561&amp;oldid=prev"/>
				<updated>2009-05-20T15:11:21Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;route_match examples&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:11, 20 May 2009&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Things to know about these examples:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Things to know about these examples:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;# &lt;/del&gt;A new field called 'priority' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* &lt;/ins&gt;A new field called 'priority' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;# &lt;/del&gt;A new field called 'asr_threshold' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* &lt;/ins&gt;A new field called 'asr_threshold' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;# &lt;/del&gt;A new field called 'usage_threshold' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* &lt;/ins&gt;A new field called 'usage_threshold' needs to be add to the routes.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 32:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 32:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; {:name =&amp;gt; 'sip_p3' }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; {:name =&amp;gt; 'sip_p3' }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; ]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; ]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== :call_field_name and :route_field_name parameter ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== :call_field_name and :route_field_name parameter ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:version:1.11a:oldid:560:newid:561 --&gt;
&lt;/table&gt;</summary>
		<author><name>10.0.0.157</name></author>	</entry>

	<entry>
		<id>https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=560&amp;oldid=prev</id>
		<title>10.0.0.157: New page: == route_match tutorial ==  'route_match' is a method implemented in the base_routing and is use to match a route to a call through parameters and/or status. This tutorial will explain how...</title>
		<link rel="alternate" type="text/html" href="https://docs.telcobridges.com/mediawiki/index.php?title=Routing_script_tutorial:route_match_Tutorial&amp;diff=560&amp;oldid=prev"/>
				<updated>2009-05-20T15:08:26Z</updated>
		
		<summary type="html">&lt;p&gt;New page: == route_match tutorial ==  &amp;#039;route_match&amp;#039; is a method implemented in the base_routing and is use to match a route to a call through parameters and/or status. This tutorial will explain how...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== route_match tutorial ==&lt;br /&gt;
&lt;br /&gt;
'route_match' is a method implemented in the base_routing and is use to match a route to a call through parameters and/or status. This tutorial will explain how to use the parameter for the 'route_match' method. &lt;br /&gt;
&lt;br /&gt;
=== route_match examples ===&lt;br /&gt;
----&lt;br /&gt;
Things to know about these examples:&lt;br /&gt;
# A new field called 'priority' needs to be add to the routes.&lt;br /&gt;
# A new field called 'asr_threshold' needs to be add to the routes.&lt;br /&gt;
# A new field called 'usage_threshold' needs to be add to the routes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== route_match setup ====&lt;br /&gt;
Time to take a look how to match route to a call. List of routes use for the example:&lt;br /&gt;
  Calling      Called      NAP      Remapped NAP       Priority&lt;br /&gt;
  5550000     1110000     isdn       sip                4     &lt;br /&gt;
  5550000     2220000     sip        isdn               3     &lt;br /&gt;
  5550000     3330000     sip_p2     isdn_1             2     &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
List of naps:&lt;br /&gt;
  Name       Asr threshold       Usage threshold   &lt;br /&gt;
  isdn         40                 90     &lt;br /&gt;
  sip          52                 92     &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Input used in the test script window:&lt;br /&gt;
  @call_params = {:calling =&amp;gt; '5550000', :called =&amp;gt; '5550002', :nap =&amp;gt; 'isdn'}&lt;br /&gt;
  @nap_list = [&lt;br /&gt;
    {:name =&amp;gt; 'sip', },&lt;br /&gt;
    {:name =&amp;gt; 'isdn' },&lt;br /&gt;
    {:name =&amp;gt; 'sip_p3' }&lt;br /&gt;
  ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== :call_field_name and :route_field_name parameter ===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== :call_field_name and :route_field_name script example ====&lt;br /&gt;
&lt;br /&gt;
Let's start with the :call_field_name and :route_field_name combo. The first example shows how to use the :call_field_name to match the calling number of the incoming call with the calling number of the route. &lt;br /&gt;
&lt;br /&gt;
It will also try to find a route which has the same remapped nap parameter as the nap parameter of the incoming call, therefore ignoring the nap parameter of the route. &lt;br /&gt;
  require 'base_routing'&lt;br /&gt;
  &lt;br /&gt;
  class MatchTutorial &amp;lt; BaseRouting&lt;br /&gt;
    route_match :call_field_name =&amp;gt; :calling&lt;br /&gt;
    route_match :call_field_name =&amp;gt; :calling, :route_field_name =&amp;gt; :calling&lt;br /&gt;
    route_match :call_field_name =&amp;gt; :nap, :route_field_name =&amp;gt; :remapped_nap&lt;br /&gt;
  &lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  @@routing = MatchTutorial.new&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  def init_routes( routes )&lt;br /&gt;
    @@routing.init routes&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  def route( call, nap_list )&lt;br /&gt;
    @@routing.route call, nap_list&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== :call_field_name and :route_field_name script output ====&lt;br /&gt;
&lt;br /&gt;
If you look at the first 2 lines of the MatchTutorial class definition:&lt;br /&gt;
  route_match :call_field_name =&amp;gt; :calling&lt;br /&gt;
  route_match :call_field_name =&amp;gt; :calling, :route_field_name =&amp;gt; :calling&lt;br /&gt;
&lt;br /&gt;
Both lines do the exact same thing. The both try to match the calling number of the incoming call with the calling number of the routing call. &lt;br /&gt;
&lt;br /&gt;
By default the if the :route_field_name is not explicitly declared, route_match will try to match the parameter from the :call_field_name to the same parameter in the route (in this case :calling). It is also important to notice that the :route_field_name parameter cannot be use without a :call_field_name parameter first.&lt;br /&gt;
&lt;br /&gt;
It is also important to notice that the called number, the nap and the priority in the routes were ignored by our match rules.&lt;br /&gt;
&lt;br /&gt;
The script will find a match. Here is the output:&lt;br /&gt;
  Call Params:&lt;br /&gt;
    Reason:        ok&lt;br /&gt;
    Called:        5550002&lt;br /&gt;
    Calling:       5550000&lt;br /&gt;
    Nap:           isdn&lt;br /&gt;
  Matched route:&lt;br /&gt;
    Remapped calling:    &lt;br /&gt;
    Called:        2220000&lt;br /&gt;
    Calling:       5550000&lt;br /&gt;
    Remapped called:    &lt;br /&gt;
    Priority:      3&lt;br /&gt;
    Remapped nap:  isdn&lt;br /&gt;
    Nap:           sip&lt;br /&gt;
  Output: OUT: Nap attribute must be remapped&lt;br /&gt;
  OUT: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== :method and :proc parameter ===&lt;br /&gt;
----&lt;br /&gt;
Let's try the :method and :proc. The next example is a isdn-sip gateway. &lt;br /&gt;
&lt;br /&gt;
It uses the one of the method contain in base_routing (:match_nap_availability), it will compare the :asr_statistics_struct_last_24h_asr_percent nap status with the :asr_threshold in the naps, and will also compare the :usage_percent nap status with the :usage_threshold. &lt;br /&gt;
&lt;br /&gt;
The threshold and the status in this example were set so that a sip to isdn call will be dropped, but a isdn to sip call will be accepted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== :method and :proc input ====&lt;br /&gt;
It is possible to set the nap status values in the test windows. Here is the input in the test window:&lt;br /&gt;
  @call_params = {:calling =&amp;gt; '5550000', :called =&amp;gt; '5550002', :nap =&amp;gt; 'isdn'}&lt;br /&gt;
  @nap_list = [&lt;br /&gt;
    {:name =&amp;gt; 'sip', :availability_percent =&amp;gt; '100', :asr_statistics_struct_last_24h_asr_percent =&amp;gt; '60', :usage_percent =&amp;gt; '85'  },&lt;br /&gt;
    {:name =&amp;gt; 'isdn', :availability_percent =&amp;gt; '100', :asr_statistics_struct_last_24h_asr_percent =&amp;gt; '40', :usage_percent =&amp;gt; '100' },&lt;br /&gt;
    {:name =&amp;gt; 'sip_p3', :availability_percent =&amp;gt; '0', :asr_statistics_struct_last_24h_asr_percent =&amp;gt; '10', :usage_percent =&amp;gt; '90' }&lt;br /&gt;
  ]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== :method and :proc script example ====&lt;br /&gt;
  require 'base_routing'&lt;br /&gt;
  &lt;br /&gt;
  #&lt;br /&gt;
  #  This class requires that your add columns in the nap called asr_threshold and usage_threshold&lt;br /&gt;
  #&lt;br /&gt;
  class MatchProcMethodTutorial &amp;lt; BaseRouting&lt;br /&gt;
    route_match :call_field_name =&amp;gt; :nap&lt;br /&gt;
    route_match :method =&amp;gt; :match_nap_availability&lt;br /&gt;
    route_match :method =&amp;gt; :match_nap_available_call&lt;br /&gt;
    route_match :proc =&amp;gt; Proc.new { |route, call, nap_list|&lt;br /&gt;
      result = true&lt;br /&gt;
      #get the outgoing nap&lt;br /&gt;
      nap=nap_list[route[:remapped_nap].intern]&lt;br /&gt;
      puts &amp;quot;usage remapped nap #{nap[:name]}&amp;quot;&lt;br /&gt;
      if nap.nil?&lt;br /&gt;
        puts &amp;quot;Cannot found route with outgoing nap '#{route[:remapped_nap]}'&amp;quot;&lt;br /&gt;
        result = false&lt;br /&gt;
      end&lt;br /&gt;
  &lt;br /&gt;
      #get the last 24hrs asr&lt;br /&gt;
      asr_24hrs_status = nap[:asr_statistics_struct_last_24h_asr_percent].to_i&lt;br /&gt;
      asr_24hrs_threshold = nap[:asr_threshold].to_i&lt;br /&gt;
      puts &amp;quot;asr status #{asr_24hrs_status}, treshold#{asr_24hrs_threshold}&amp;quot;&lt;br /&gt;
      if asr_24hrs_status &amp;lt; asr_24hrs_threshold&lt;br /&gt;
        puts &amp;quot;Insufficient ASR in the last 24hrs for nap '#{route[:remapped_nap]}'&amp;quot;&lt;br /&gt;
         result = false&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      result&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    def match_nap_available_call(route, call, nap_list)&lt;br /&gt;
      #get the outgoing nap&lt;br /&gt;
      nap=nap_list[route[:remapped_nap].intern]&lt;br /&gt;
      puts &amp;quot;usage remapped nap #{nap[:name]}&amp;quot;&lt;br /&gt;
      if nap.nil?&lt;br /&gt;
        puts &amp;quot;Cannot found route with outgoing nap '#{route[:remapped_nap]}'&amp;quot;&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      # verify how many calls are available in the nap&lt;br /&gt;
      nap_usage_status = nap[:usage_percent].to_i&lt;br /&gt;
      nap_usage_threshold = nap[:usage_threshold].to_i&lt;br /&gt;
      puts &amp;quot;usage status #{nap_usage_status}, treshold#{nap_usage_threshold}&amp;quot;&lt;br /&gt;
      if nap_usage_status &amp;gt; nap_usage_threshold&lt;br /&gt;
        puts &amp;quot;Nap usage of '#{route[:remapped_nap]}' is higher then threshold '#{nap_usage_status}' &amp;quot;&lt;br /&gt;
        return false&lt;br /&gt;
      end&lt;br /&gt;
  &lt;br /&gt;
      true&lt;br /&gt;
  &lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  @@routing = MatchProcMethodTutorial.new&lt;br /&gt;
  &lt;br /&gt;
  def init_routes( routes )&lt;br /&gt;
    @@routing.init routes&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  def route( call, nap_list )&lt;br /&gt;
    @@routing.route call, nap_list&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== :method and :proc output ====&lt;br /&gt;
The gateway application queries every second the status and keep it available for routing script (due to the synchronous nature of the status query, it is preferable to have another thread polling the status than querying the status for each call). &lt;br /&gt;
&lt;br /&gt;
The script uses 2 status available (:asr_statistics_struct_last_24h_asr_percent and :asr_threshold in the naps) in the naps, for a complete list of the status available go [[knowledgebase:toolpack:script_routing#nap_statuses|here]] in the NAP_STATS_FIELDS define. &lt;br /&gt;
&lt;br /&gt;
If you check the NAP_STATS_FIELDS define, you will see that :asr_statistics_struct_last_24h_asr_percent is the combination of 2 field names asr_statistics_struct and last_24h_asr_percent.&lt;br /&gt;
&lt;br /&gt;
You might have noticed that the block in the proc function did not use the return keyword, it is a rule from ruby where you cannot use the return keyword in a block.&lt;br /&gt;
&lt;br /&gt;
Here is the output:&lt;br /&gt;
  Call Params:&lt;br /&gt;
    Reason:        ok&lt;br /&gt;
    Called:        5550002&lt;br /&gt;
    Calling:       5550000&lt;br /&gt;
    Nap:           isdn&lt;br /&gt;
  Matched route:&lt;br /&gt;
    Remapped calling:    &lt;br /&gt;
    Called:        1110000&lt;br /&gt;
    Calling:       5550000&lt;br /&gt;
    Remapped       called:    &lt;br /&gt;
    Priority:      4&lt;br /&gt;
    Remapped nap:  sip&lt;br /&gt;
    Nap:           isdn&lt;br /&gt;
  &lt;br /&gt;
  Output: OUT: usage remapped nap sip&lt;br /&gt;
  OUT:&lt;br /&gt;
  OUT: usage status 85, treshold92&lt;br /&gt;
  OUT:&lt;br /&gt;
  OUT: usage remapped nap sip&lt;br /&gt;
  OUT:&lt;br /&gt;
  OUT: asr status 60, treshold52&lt;br /&gt;
  OUT:&lt;br /&gt;
  OUT: Nap attribute must be remapped&lt;br /&gt;
  OUT:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Back to [[Routing_script_tutorial|Routing Script Tutorial]].&lt;/div&gt;</summary>
		<author><name>10.0.0.157</name></author>	</entry>

	</feed>