> 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/telecom-concepts/adding-routing-number-script.md).

# Adding Routing Number Script

> **Applies to:** Tmedia 2.9, 2.10, 3.0, 3.1

This article describes how to add a **Routing Number** script to any Routing scripts.

### Requirements for this script

1. The routing number is included in the incoming call. For SIP in the Request-URI: INVITE sip:0038123456789;rn=8087321000;npdi=yes\@192.168.101.160:5060
2. The routing table must use the called party number
3. The outgoing call will have: For SS7: Forward Call Indicators: Ported number translation indicator: number translated (Bit M) Called Party Number: 8087321000 Generic Number: \[Not present]
4. The CDR needs to have the Called number set as the Routing Number

### Add **Routing Number** Scripts in system

| Download this file                                                        |
| ------------------------------------------------------------------------- |
| \*[R\_n\_cdr.rb](https://docs.telcobridges.com/w/images/d/db/R_n_cdr.zip) |

Then upload it in the system with these instructions: [Import\_Customized\_Routing\_Script\_C](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/api/import-customized-routing-script/README.md)

### Setting up **Routing Number** Scripts

To set up a Filter, the main script needs to be modified. The main script can be either simple\_routing.rb, simple\_routing\_sbc.rb, or any other script.

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

```
Gateway -&gt; Routing scripts -&gt; Example Scripts -&gt; simple_routing_sbc.rb [Edit]
```

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

```
require 'r_n_cdr'
```

In the main class:

```
include RnCdr
```

```
before_filter :method => :RN_cdr
```

```
after_remap_filter :method => :Swap_back
```

The final script will look like this:

```
require 'base_routing'
require 'r_n_cdr'

class SimpleRouting < BaseRouting
  include RnCdr

  before_filter :method => :RN_cdr

  route_match :call_field_name => :called
  route_match :call_field_name => :calling
  route_match :call_field_name => :nap
  route_remap :call_field_name => :called, :route_field_name => :remapped_called
  route_remap :call_field_name => :calling, :route_field_name => :remapped_calling
  route_remap :call_field_name => :nap, :route_field_name => :remapped_nap

  after_remap_filter :method => :Swap_back
end
```

### Update Text CDR Configuration

To have the Routing Number (RN) in the CDR logs, add these fields: Gateway -> Text CDR parameters -> CDR format (Start): ,RN='@{ScriptAttribute:RN}' Gateway -> Text CDR parameters -> CDR format (End): ,RN='@{ScriptAttribute:RN}' And replace the called fields: Gateway -> Text CDR parameters -> CDR format (Start): ,Called='@{ScriptAttribute:Called2}' Gateway -> Text CDR parameters -> CDR format (End): ,Called='@{ScriptAttribute:Called2}' See instructions here: [Text\_Call\_Detail\_Records](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/text-call-detail-records/README.md)

### Configure LNP Settings

LNP settings need to be: profiles -> Outgoing calls LNP mode: Relay LNP Information profiles -> Incoming calls LNP mode: Forward LNP from incoming to outgoing call See instructions here: [Modify\_LNP\_profile\_D](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/concepts/modifying-lnp-profile-settings/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/telecom-concepts/adding-routing-number-script.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.
