[Freeswitch-users] More playing with sessions in lua

Troy Anderson troy at tlainvestments.com
Mon Jan 18 11:11:31 PST 2010


I think there may be other ways to do this, but if I could understand how to do it from lua, I think it would help me understand more about what's going on and make the mod_lua even more valuable to me and anyone else struggling with this kind of issue.

I am trying to answer a call in lua, exchange a bit of information with the caller, then I want to originate a call to another endpoint, and depending on what their response to some audio questions is, connect the original caller to them, or send the original caller away.  The problem is that I want the original caller to her ring tones or music on hold while they're waiting.  In addition to the way presented here, I've tried parking the caller using uuid_park, but still can't figure out how to play music/ringback for them.

session:answer();
session:sleep(1000);
session:execute("playback","pleasehold.wav")

local targetEndpoint = "1100 at default" -- or wherever

-- ringback works only AFTER the bridge line, below.  How do I get it to start immediately?
local destSession = freeswitch.Session("{ringback='myringback.wav'}".. targetEndpoint)	-- this "originates" a call to targetEndpoint

local digit destSession:playAndGetDigits(1,1,3,3000,"#","instructions.wav","[1-3]")

if (digit == "1") then
	freeswitch.bridge(session,destSession)
else
	session:execute("playback","goodbye.wav")
	session:hangup()
	destSession:hangup()
end


I appreciate any help on this.

-Troy




More information about the FreeSWITCH-users mailing list