Play audio and Get digits from IVR on outbound call

Hi Everyone,
I want to create an IVR in FusionPBX, my scenario is...

I wan to initiate an outgoing call which plays a (.wav) message. The caller must confirm this message (press 9) or repeat the voice-message (press 3).
The output (9) must best sent back to mij BASH script. This can be an exit code (1 or 0) or an other definition.
Number which must be called must be specified by calling the script and also the (.wav) message.

can anyone help me regarding this.


Active Member
My initial thought it to write it in LUA instead of BASH. Most people on this forum will script FS with lua. FusionPBX has a whole bunch of scripts from which to pull ideas and examples.

Read through the wakeup script for ideas to get you started for something similar to what you are trying to do.

You can use fs_cli -x "luarun myscript.lua" to start the script from command line.

Perhaps in the lua script you could log the key press results to a file, then read the file with your bash script.
Hey @Agha Assad , have you been lucky with this? I am trying to do the same but I cannot figure out how to do it for an outbound call. For incoming calls it is pretty straightforward.

I thought it was something like bridging the call and then playing back the audio but it does not seem to be the case for we do not want to bridge anything, just create a one leg call.

If I am able to figure it out I will let you know.
OK... I managed to get this working. This is very raw but it does what I need which is, in essence, what @Agha Assad was looking for as well:

    outbound_number = 'xxxxxxxxxxx'; -- Number to dial:
    outbound_trunk = 'xxxxxxx-xxxxx-xxx-xxx-xxxxxxxxxx'; --My GW ID
    audio_to_play = 'ask_for_input.wav'
    audio_to_play_if_invalid_input = 'notvalid.wav'   
    pattern = '^0$|^1$|^2$';  -- I only accept 0-2.
    session = freeswitch.Session('sofia/gateway/' .. outbound_trunk .. '/' .. outbound_number, session);
    caller_input = session:playAndGetDigits(1, 1, 3, 10000, '#', audio_to_play, audio_to_play_if_invalid_input, pattern, caller_input, 2000);
    freeswitch.consoleLog(NOTIFY, The input was :: ' .. caller_input .. '.\n');
Of course it has to be polished and completed so it does something useful but the bare-bone functionality is there.