[Freeswitch-users] How to start IVR script via dialplan by making an outbound call

king2kin xing2kin at yahoo.com
Tue Aug 30 13:26:50 MSD 2011


Thank for your reply. Something seems wrong with 'record' for out dial IVR.

I made a simple dialplan and Lua script for testing IVR started by outbound-call instead of inbound call as follows:

- xml dialplan extension "8887":
{
<include>
	<extension name="Simple IVR Lua Test">
	<condition field="destination_number" expression="^(8887)$">
		<action application="lua" data="test1.lua"/>
	</condition>
	</extension> 
</include>
}

- Lua script "test1.lua"
{

-- test1.lua
-- Answer call, play a prompt, record a msg, play back msg, hangup

-- Set the path separator
pathsep = '/'

-- Windows users do this instead:
-- pathsep = '\'

--Answer the call
session:answer()

--Create a string with path and filename of a sound file
prompt = "ivr" .. pathsep .. "ivr-welcome_to_freeswitch.wav"

-- Print a log message
freeswitch.consoleLog("INFO","Prompt file is '" .. prompt .. "'\n")

--Play the prompt
session:streamFile(prompt)

-- Record record file
session:streamFile("phrase:voicemail_record_message")
			
-- Play a ""bong"" tone prior to recording
session:streamFile("tone_stream://v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1000, 0, 640)")

-- record a message
filename = session:getVariable('sounds_dir') .. pathsep .. "123.wav"
session:recordFile(filename,300,100,10)

-- play back the recorded msg
session:streamFile(filename)

-- Hangup
session:hangup()
}

- Testing results:

1. call FS IVR normally by an inbound call via X-Lite with user/1005

{
dial 8887
}
then, everything runs as what I expect; it may answer call, play a prompt, record a msg, play back msg, hangup.

2. call FS IVR by an outbound call (FS call a user who picks up the call, then follow IVR to take actions)

from the command-line of Freewitch, I type the following command:
{
originate user/1005 &transfer(8887 xml default)
}
As soon as the above command is submitted, X-Lite of user/1005 rings, I hit button of X-Lite to answer the call, ok it plays prompt and pong tone,
I start to speak until I hit a dtmf button '#', it stops recording, however, nothing is recorded and the file is empty although a sound file "123.wav" (this filename was hardcoded) was indeeded generated on the disk.

I don't know why recordFile does NOT work for the case of outbound call IVR, but recordFile does work for inbound call IVR; they share the same dialplan extension and IVR Lua script. What's problem here? I also tried
"session:record(...)" and "session:record_session(...)", they all didn't work for outbound call IVR.

3. I also tried your testing command with "bridge", e.g.
{
originate user/1005 &bridge(user/8887)
or
originate user/1005 &bridge(user/8887 at default) 
}

"bridge" basically doesn't work for my case.

I read another post from someone else, which mentioned that sip "record" always failed after 32 seconds. Is it possible that sip "record" has a bug?


--- On Mon, 8/29/11, Isaac Jurado <ijurado at econcept.es> wrote:

> From: Isaac Jurado <ijurado at econcept.es>
> Subject: Re: [Freeswitch-users] How to start IVR script via dialplan by making an outbound call
> To: "FreeSWITCH Users Help" <freeswitch-users at lists.freeswitch.org>
> Date: Monday, August 29, 2011, 2:31 PM
> On Mon, Aug 29, 2011 at 7:24 PM,
> king2kin <xing2kin at yahoo.com>
> wrote:
> > Hi folks,
> >
> > It's easy to start to run IVR script by an inbound
> call on FreeSwitch.
> > However, I don't know to start to run IVR script in
> the following
> > case:
> >
> > I'd like to run an external client application which
> will ask
> > FreeSwitch to make an outbound call to a mobile phone
> number, when the
> > phone rings, someone picks it up and then she/he
> starts to interact
> > with FreeSwitch normally like an inbount-call
> initiates to run IVR
> > script.
> >
> > Could anyone please give me some advice?
> 
> I think that, from the FreeSWITCH console you can do
> something like:
> 
> originate path/to/mobile_num
> &bridge(path/to/special_extension)
> 
> And configure "path/to/special_extension" to execute the
> "ivr" dialplan
> application.
> 
> Cheers.
> 
> -- 
> Isaac Jurado
> Internet Busines Solutions eConcept
> 
> 
> 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
> 



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