Play audio and Get digits from IVR on outbound call

Status
Not open for further replies.

Agha Assad

New Member
Dec 21, 2019
7
1
3
28
Pakistan
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.
 

KonradSC

Active Member
Mar 10, 2017
166
98
28
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. https://github.com/fusionpbx/fusionpbx/blob/master/app/scripts/resources/scripts/wakeup.lua

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.
 

ewdpb

Member
Oct 3, 2019
151
19
18
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.
 

ewdpb

Member
Oct 3, 2019
151
19
18
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:

Code:
    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.
 

Agha Assad

New Member
Dec 21, 2019
7
1
3
28
Pakistan
Thanks for your help @ewdpb , currently I am working on something else, I'll try it and then let you know, I was stuck in this that's why i left it and doing something else.
 
Status
Not open for further replies.