[Freeswitch-users] Handling Multi Call in Lua
Shahzad Bhatti
shahzad.bhatti at g-r-v.com
Thu Jun 28 18:40:32 MSD 2012
i want to originate 5 calls after one second sleep using lua and get the
response using playandgetdigits(), but scipt originate call one by one.
please guide me how i can call 5 numbers at the same time,
here is my code
===============================================================================================================================
*-- TestCall.lua*
function PlayMessageAndGetResponse(message)
count = 1
invalid = 'say:flite:slt:nvalid input , please enter again'
audio_for_prompt = 'say:flite:slt:press 1 for YES, Press 2 for No,
Press 3 for Record Message and Press 4 for Replay'
while session:ready() == true and count <= 3 do
session:sleep(250)
session:streamFile(message)
session:sleep(250)
digits = session:playAndGetDigits(1, 1, 3, 5, "#",
audio_for_prompt, invalid, "^(1|2|3|4)$")
if digits == "" then
return 0
elseif digits == "4" then
count = count + 1
else
return digits
end
end
return 0
end
number = argv[1]
message= argv[2]
greeting = "Welcome! You have a Mesage"
bye_message = "Bye bye."
response = 0
freeswitch.consoleLog("info", "The Number "..number..", message
"..message.."\n")
session =
freeswitch.Session("{ignore_early_media=true,origination_caller_id_number=321}user/"..number.."")
session:setAutoHangup(false)
session:set_tts_parms("flite", "slt")
dispoA = "None"
while(session:ready() and dispoA ~= "ANSWER") do
dispoA = session:getVariable("endpoint_disposition")
freeswitch.consoleLog("INFO","Leg A disposition is '" ..
dispoA .. "'\n")
os.execute("sleep 1")
end -- legA while
if session:ready() == true and dispoA == "ANSWER" then
uuid = session:getVariable("uuid")
session:speak(greeting)
response = PlayMessageAndGetResponse(message)
session:speak(bye_message)
session:hangup()
end
cause = session:hangupCause()
session:destroy()
freeswitch.consoleLog('info',"Number "..number..", respond
"..response.." hangup cause is "..cause.."\n")
===============================================================================================================================
*-- campaign.lua*
count = 1000
number = {}
for i = 1, 5 do
number[i] = count
count = count + 1
end
for i = 1, 5 do
freeswitch.consoleLog("warning", "Calling " ..number[i].. "\n")
api = freeswitch.API();
reply = api:executeString("luarun TestCall.lua "..number[i].."
".."test_msg.wav")
os.execute("sleep 1")
end
===============================================================================================================================
Regards
Shahzad Bhatti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120628/ca81ccd5/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list