> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/apis-and-integration/route-remap-tutorial.md).

# route remap Tutorial

### route\_remap tutorial

'route\_remap' is a method implemented in the base\_routing and is use to modify call parameters per route (allowing to change call attributes in a different manner per route). This tutorial will explain how to use the parameter for the 'route\_remap' method.

#### route\_remap examples

***

Things to know about these examples:

* A new field called 'priority' needs to be add to the routes.
* A new field called 'asr\_threshold' needs to be add to the routes.
* A new field called 'usage\_threshold' needs to be add to the routes.

**route\_remap setup**

Time to take a look how to match route to a call. List of routes use for the example: Calling Called NAP Remapped NAP Priority 5550000 1110000 isdn sip 4 5550000 2220000 sip isdn 3 5550000 3330000 sip\_p2 isdn\_1 2

List of naps: Name Asr threshold Usage threshold isdn 40 90 sip 52 92

Input used in the test script window: @call\_params = {:calling => '5550000', :called => '5550002', :nap => 'isdn'} @nap\_list = \[ {:name => 'sip', }, {:name => 'isdn' }, {:name => 'sip\_p3' } ]

#### route\_remap parameter

***

The following example is a isdn to sip gateway. This time we will remap the called and the calling number. require 'base\_routing'

```
class RemapTutorial < BaseRouting
route_match :call_field_name => :nap
route_remap :call_field_name => :called, :route_field_name => :called
route_remap :method => :remapped_tutorial
route_remap :proc => Proc.new { |route, caf_call, nap_list, call_params|

puts "Proc is called"
```

1. remapping calling remap\_calling = call\_params\[:calling] puts "remapped : #{remap\_calling}"

   if( remap\_calling == "5550000" ) remap\_calling = "9871111" elsif ( remap\_calling == "7772222") remap\_calling = "6541111" end

   puts "remap\_calling : #{remap\_calling}" call\_params\[:calling] = remap\_calling

   call\_params }

   def remapped\_tutorial(route, caf\_call, nap\_list, call\_params)

   puts "Method is called" remap\_calling = call\_params\[:calling] puts "remapped : #{remap\_calling}"

   if( remap\_calling == "5550000" ) remap\_calling = "7772222" elsif( remap\_calling == "9871111" ) remap\_calling = "9992222" end

   puts "remap\_calling : #{remap\_calling}" call\_params\[:calling] = remap\_calling

   call\_params

   end

   end

   @@routing = RemapTutorial.new

   def init\_routes( routes ) @@routing.init routes end

   def route( call, nap\_list ) @@routing.route call, nap\_list end

**route\_remap script output**

The called number is remapped by the the :call\_field\_name / :route\_field\_name. Like 'route\_match', if :call\_field\_name is used alone the parameter (in this case :called), will be remapped by the same parameter of :route\_field\_name. The following 2 lines will have the exact same behavior (they both remapped the called number of the call with the called number of the route): route\_remap :call\_field\_name => :called route\_remap :call\_field\_name => :called, :route\_field\_name => :called

As for the :method and :proc parameters, they both remap the calling number but to different values.

The remapping result needs to be inserted in call\_params hash and return in your method or proc. All remap function return remapped parameter in the call\_params. They are executed in the order they are declared.

Here is the output of the example: Call Params: Reason: ok Called: 2220000 Calling: 6541111 Nap: sip Matched route: Remapped calling: Called: 2220000 Calling: 5550000 Remapped called: Priority: 3 Remapped nap: isdn Nap: sip Output: OUT: Method is called OUT: OUT: call : 5550000 OUT: OUT: remap\_calling : 7772222 OUT: OUT: Proc is called OUT: OUT: remapped : 7772222 OUT: OUT: remap\_calling : 6541111 OUT: OUT: Nap attribute must be remapped OUT:

***

Back to [Routing Script Tutorial](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/api/routing-script-tutorial/README.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/apis-and-integration/route-remap-tutorial.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
