> 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/voice-and-media/adding-capture-dtmf-script.md).

# Adding Capture DTMF Script

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

This arcticle describes how to add a **Capture DTMF** script to any Routing script.

**Script Description**

If the called number is a specific value, it will play an announcement and wait to capture digits.

1. Call 1-800-999-4444
2. Hear tone
3. Enter 2 digit switch number optionally followed by #
4. Hear tone
5. Enter TG number – can be 4 or 5 digits depending on which switch the call goes to
6. Hear tone
7. Enter destination number

The call then routes to a TG (NAP) based on the 2-digit switch number, and the INVITE contains the TG number in the TGRP= parameter. Sample INVITE with TGRP= INVITE sip:18003608022\@192.168.101.180;tgrp=98741 SIP/2.0 This will work with any TMG device with a license to play files. For ProSBC, it requires transcoding devices.

**Add Capture DTMF Scripts in system**

Download this file:

| Capture DTMF Script                                                                |
| ---------------------------------------------------------------------------------- |
| \*[capture\_dtmf.rb](https://docs.telcobridges.com/w/images/a/a7/Capture_dtmf.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 Capture DTMF 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.rb [Edit]
```

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

```
require 'capture_dtmf'
```

In the main class:

```
include CaptureDTMF
```

```
after_filter :method => :capture_dtmf
```

The final script will look like this:

```
require 'base_routing'
require 'capture_dtmf'

class SimpleRouting < BaseRouting
  include CaptureDTMF

  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_filter :method => :capture_dtmf
end
```

**Upload audio file**

The script will play a tone for the user to ask them to enter a dtmf string. This show how to add the default one which can be downloaded here:

| Sample Tone File                                                                                   |
| -------------------------------------------------------------------------------------------------- |
| \*[fen-tone-400hz-300ms.wav](https://docs.telcobridges.com/w/images/5/56/Fen-tone-400hz-300ms.wav) |

1. Click **Audio Prompts** in the navigation panel
2. Click **Browse** and select 'fen-tone-400hz-300ms.wav'
3. Click **Upload**

See instructions here: [Toolpack:Configuring\_Audio\_Prompts\_C](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/configuring-audio-prompts/README.md)

However any G.711 alaw or G.711 ulaw wav file can be added to the system to be played: you need to edit the capture\_dtmf.rb script with the appropriate wav file.


---

# 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/voice-and-media/adding-capture-dtmf-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.
