Schedule "play and get digits" during bridged call

Hi,
I am looking for a way to add the ability to schedule a play and get digits to capture a key entry after a given time after two channels are bridged.

If a key is pressed, the play and get digits should be scheduled for another x minutes and so on.

I am currently testing having an api_on_answer firing on the bridge which runs a javascript script. This script loops until the time has elapsed (or !session.ready()) and then fires the play and get digits using
session.execute(“play_and_get_digits”, “1 1 1 5000 # goodfile badfile keyPressVar”);
Now this does work to a degree, in that the audio file plays and can be heard, the DTMF tones are being received but the audio file continues to play and the keyPressVar is not populated.

Any help would be appreciated.

Do you need them realtime? If so you can use (mod_dptools: bind_digit_action | FreeSWITCH Documentation)

Hi Brian,

thanks for the response. Yes realtime is needed. Essentially what I am trying to achieve is playing a prompt to the A party asking them to confirm they wish to continue on with the call.

Bind digits wouldn’t work in this scenario (at least not that I can think of), as I would not want the caller to be able to press the digit prior to the prompt being played.

I do have a test running which works in part, but does not capture the digit from the play_and_get_digits.

I have the below javascript code execute via api_on_answer. So when the B leg answers and the calls are bridged, it waits until a duration is reached and then executes the play and get digits.
This code works, in that it plays the prompt, and when the keypress is made, the DTMF packet is received by Freeswitch, but it is not captured by the play and get and so is not assigned to the variable.
I feel it is likely to be something to do with the session being created off of the uuid, or the DTMF context being incorrect.

var maxTime = argv[0];
var startDate = new Date();
var currentDate = new Date();

while (session.ready())
{
    msleep(300);
    currentDate = new Date();

    if (session.ready() && (currentDate.getTime() - startDate.getTime())/ 1000 > maxTime)</i></b>
    {
        Digits = "";
        Output("digits:"+Digits);
        session.execute("play_and_get_digits", "1 1 1 5000 # http_cache://[https://file.]https://file.${read_codec} http_cache://file.${read_codec} pressedDigit");
        Digits = session.getVariable("pressedDigit");
    }
}

You should be using the sesssion.playAndGetDigits and not session.execute, If its not there in V8 it may just need to be wrapped and added to the session object like Lua has it already.

/b