[Freeswitch-users] Executing multiple applications in parallel

Ben Langfeld ben at langfeld.co.uk
Sat Jan 26 14:21:23 MSK 2013


For anyone wondering, Adhearsion (http://adhearsion.com) can do this kind
of thing quite easily. I know you said ES is not an option for you, but you
might consider it in future.

Regards,
Ben Langfeld


On 26 January 2013 03:46, Brian Wiese <brian.wiese.freeswitch at gmail.com>wrote:

> JP:
>
> Give this a try:
>
> =====  Dialplan Extension  =====
> <extension name="Wait for Lua">
>   <condition field="destination_number" expression="^29000$">
>     <action application="pre_answer"/>
>     <action application="eval" data="${luarun(wait.lua ${uuid})}"/>
>     <action application="playback"
> data="ivr/ivr-on_hold_indefinitely.wav"/>  <!-- Obviously replace with
> a sound file containing music or something... -->
>     <!-- If the Lua script fails or times out (the above sound file
> played completely), do something so the user doesn't sit around
> forever... -->
>     <action application="sleep" data="2000"/>
>     <action application="playback" data="misc/error.wav"/>
>     <action application="sleep" data="2000"/>
>     <action application="playback" data="voicemail/vm-goodbye.wav"/>
>     <action application="hangup"/>
>   </condition>
> </extension>
> ==========
>
> =====  Lua Script (wait.lua)  =====
> api = freeswitch.API();
>
> uuid = argv[1];  --The UUID of the call.
>
> if uuid == nil then
>   freeswitch.consoleLog("crit","Fatal Error:  A UUID was not passed to
> the script!\n");
> else
>   freeswitch.consoleLog("info","Working...\n");
>
>   --Do the task here that may take some time...
>
>   session = freeswitch.Session(uuid);
>   freeswitch.consoleLog("info","Transferring call!\n");
>   session:transfer("lua_done");  --Obviously set this to a dialplan
> extension...
> end
> ==========
>
>
> Using this method you can even make the dialplan as one extension (use
> extension "29000step2" for session:transfer in the Lua script):
>
> ====  Dialplan Single Extension Example =====
> <extension name="Wait for Lua">
>   <condition field="destination_number" expression="^29000(?:step2)?$"/>
>   <condition field="destination_number" expression="^29000$"
> break="on-true">
>     <action application="pre_answer"/>
>     <action application="eval" data="${luarun(wait.lua ${uuid})}"/>
>     <action application="playback"
> data="ivr/ivr-on_hold_indefinitely.wav"/>  <!-- Obviously replace with
> a sound file containing music or something... -->
>     <!-- If the Lua script fails or times out (the above sound file
> played completely), do something so the user doesn't sit around
> forever... -->
>     <action application="sleep" data="2000"/>
>     <action application="playback" data="misc/error.wav"/>
>     <action application="sleep" data="2000"/>
>     <action application="playback" data="voicemail/vm-goodbye.wav"/>
>     <action application="sleep" data="500"/>
>     <action application="hangup"/>
>   </condition>
>   <condition field="destination_number" expression="^29000step2$">
>     <action application="answer"/>
>     <action application="sleep" data="500"/>
>     <action application="playback"
> data="ivr/ivr-yes_we_have_no_bananas.wav"/>
>     <action application="sleep" data="500"/>
>     <action application="hangup"/>
>   </condition>
> </extension>
> ==========
>
> ~Brian
>
> On Thu, Jan 24, 2013 at 7:34 PM, JP <jaykris at gmail.com> wrote:
> > I want to do the following...
> >
> > 1. Play a long music file from a dialplan.
> > 2. While the music is playing, I want to launch a Lua script to do some
> data
> > dip.
> > 3. Once the data is fetched and Lua exits, I want to interrupt the music
> and
> > continue in the dialplan
> >
> > How do I do this. Any sample code or pointers would be greatly
> appreciated.
> >
> > Thanks
> >
> > _________________________________________________________________________
> > Professional FreeSWITCH Consulting Services:
> > consulting at freeswitch.org
> > http://www.freeswitchsolutions.com
> >
> > 
> > 
> >
> > Official FreeSWITCH Sites
> > http://www.freeswitch.org
> > http://wiki.freeswitch.org
> > http://www.cluecon.com
> >
> > FreeSWITCH-users mailing list
> > FreeSWITCH-users at lists.freeswitch.org
> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> > http://www.freeswitch.org
> >
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130126/7b5fa47c/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list