Page tree
Skip to end of metadata
Go to start of metadata

About

Bind a key sequence or regex to an action. 

 

 Click here to expand Table of Contents

Description

The bind_digit_action application is very similar to bind_meta_app but is better and more flexible. It can be used to replace bind_meta_app in all cases.

bind_digit_action uses the concept of ''realms'' for binding various actions. A realm is similar to a dialplan context where the dialed number means something different depending upon which context the call is in. (See the example below.)

You may bind one or more digits to an action, and you may also use [[regex|regular expressions]]. Note that you cannot "capture" digits in bind_digit_action,.

To clear or remove the digit bindings, use clear_digit_action.

Usage

 

realm — the digit realm, somewhat similar to a dialplan context

digits — the digits to match

 OR

~regex — the regular expression to match

string — the dialplan or api command, e.g. "exec:<dialplan app>", e.g. "api:<api app>"

Optional:

value — contains the arguments to the command string

dtmf target leg — aleg, bleg, peer, both; defaults to aleg

event target leg — aleg, bleg, peer, both; defaults to aleg

Channel Variables

bind_digit_digit_timeout

Interdigit timeout, in milliseconds. Default = 1500 msec. This sets the time to wait between individual dialled digits. Mostly only useful in conjunction with play_and_get_digits in same dialplan extension.

Example: set to 10000 to wait 10 seconds between digits.

bind_digit_input_timeout

 Overall timeout, in milliseconds. Default = 0 msec. This sets the overall time to wait for the entire digit sequence to be entered.

Notes

Setting on the B leg

Here are several choices:

Set the dtmf target leg to "peer" (see above)

These 2 vars on the A leg using the set app:

This var with export app:

These vars with export app:

or one of these vars in the dial string {}:

Be aware that when using bind_digit_action you may inadvertently break other apps that rely upon DTMFs. This is because any digits that match a pattern are '''consumed''' by bind_digit_action and thus will not be sent through. However, any '''non-matching''' digits will be sent through. Therefore you should make sure that you don't have any regexes that "grab everything" unless you are equipped to handle that scenario.

Using bind_digit_action with a conference 

The bind_digit_action can definitely be used with conferences, however the above rule about matching digits still applies. Make sure that any keys that you wish to be available to your callers to control the conference (i.e. the conference caller-controls) do not "match" in your bind_digit_actions. There should be no overlap or overload of defined digits.

If you have a PIN on your conference then you will need to make sure that the PIN code also does not "match" any of your bound digit actions, otherwise bind_digit_action will consume the digits that the caller dials and will *not* send them on to the conference! This results in a caller not being able to join a conference that is locked with a PIN code.

Inband vs. 2833 DTMFs

The bind_digit_action supports both inband and 2833 DTMFs. For an example on how to check the SDP for RFC 2833 and automatically start in-inband dtmf detection look in conf/dialplan/default.xml and locate the "global" extension. The 2833 detection is commented out by default.

Examples

Simple Example With Two Realms

-- or --

Advanced Example: Call Recording On/Off Switch

The following example demonstrates how to use '''bind_digit_action''' to create an on/off sequence for call recording. We'll use '''*2''' as the key sequence that toggles the record. You can use whichever key sequence you see fit. We need three different extensions for this operation:

  • The "setup recording" extension
  • The "start recording" extension
  • The "stop recording" extension


SETUP RECORDING

 

START RECORDING

STOP RECORDING

Now we need to apply this to our inbound and outbound calls. Outbound calls (A leg) are simple, just add an execute extension:

For inbound calls (or the B leg) you need to do a little bit more. Add this to the Local_Extension after the bind_meta_app calls:

Note that in this example we have taken '''*2''' away from bind_meta_app.

Catching the Digits Dialled


Sometimes it is useful to know what digit(s) the caller dialled, especially when using a regular expression to capture digits. This is done with a channel variable called [[Variable_last_matching_digits|last_matching_digits]]. The channel variable is updated with each match. This dialplan snippet demonstrates how it works:

See Also

 

 

1 Comment

  1. Call Recording On/Off Switch - work only with 1 bind, you can not make several binds - after enable|disable record and switch context we got new bindings with new realm.