> 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/transmission-and-lines/adding-timeslot-control-to-routing-scripts.md).

# Adding Timeslot Control to Routing Scripts

> **Applies to:** ProSBC 3.1, 3.2

This article describes how to add **timeslot\_control.rb** script to any Routing scripts.

The script demonstrates how to make routing decisions based on the inbound timeslot, and how to use routing decisions to select an outbound timeslot. This is useful in CAS environments where some timeslots in a T1/E1 may be used for different purposes.

### Requirements for this script

This script has been designed for controlling timeslots so the system must have TDM interfaces configured in the system. See: Allocating TDM lines

### Add **timeslot\_control.rb** Script in system

Download this file:

| timeslot control routing script                                                             |
| ------------------------------------------------------------------------------------------- |
| \*[timeslot\_control.rb](https://docs.telcobridges.com/w/images/9/9b/Timeslot_control.zip‎) |

Then uncompress and upload it in the system with these instructions: [Import Customized Routing Script](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/api/import-customized-routing-script/README.md) You can also copy/paste the content of the main file and create a new 'Main' Script using the **Create New Script File** menu

### Setting up **Timeslot Control** Script

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 with the 'Main' type.

![Main scripts](https://docs.telcobridges.com/w/images/e/e3/Main_scripts.png%E2%80%8E)

Go to the routing script section of the Web portal

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

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

```
require 'timeslot_control'
```

In the main class:

```
include TimeslotControl
```

```
   route_remap :method => :timeslot_control
```

The final 'Main' script will look like this:

```
require 'base_routing'
require 'timeslot_control'

class SimpleRouting < BaseRouting
  include TimeslotControl

  before_filter :method => :timeslot_read

  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

  route_remap :method => :timeslot_control

end
```

There may be other scripts called by this 'Main' script. This is normal.

### Adding new timeslot variable

You need to add two new custom columns to use this script. There is a default value created and it can be changed in each route afterwards. The best is to create a multiple choice option to prevent errors. In this case, it will be the list of available line services (TDM lines) that can be used for controlling the timeslots (all CAS trunks).

```
Gateway -&gt; Routes -&gt; Create New Route Column
```

**Name**: lineservice **Type attributes**: none|DS1\_01|DS1\_02|DS1\_03|...|DS1\_84 **Default**: none

The result will look like this:

![Timeslot control trunk configuration](https://docs.telcobridges.com/w/images/2/24/Timeslot_control_trunk_configuration.png%E2%80%8E%E2%80%8E)

Then you can do the same for the timeslots:

```
Gateway -&gt; Routes -&gt; Create New Route Column
```

**Name**: timeslot **Type attributes**: none|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24 **Default**: none

The result will look like this:

![Timeslot control timeslot configuration](https://docs.telcobridges.com/w/images/e/e4/Timeslot_control_timeslot_configuration.png%E2%80%8E%E2%80%8E)

You can then go in each route and change these values.

lineservice='DS1\_02' will use the second T1 configured. 'none' will disable the use of this feature.

timeslot='5' will use the timestot 5 of DS1\_02 for this route.


---

# 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/transmission-and-lines/adding-timeslot-control-to-routing-scripts.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.
