Skip to content

Instantly share code, notes, and snippets.

@avimar
Created January 23, 2013 07:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save avimar/4602781 to your computer and use it in GitHub Desktop.
Save avimar/4602781 to your computer and use it in GitHub Desktop.
Avi's Freeswitch play error lua script
calling_card = session:getVariable("calling_card_ivr")
cause = session:getVariable("originate_disposition")
cause2=session:getVariable("bridge_hangup_cause")
if cause == nil then cause="none" end
session:execute("log", "DEBUG Hangup cause: "..cause);
if cause2 == nil then cause2="none" end
session:execute("log", "DEBUG bridge hangup cause: "..cause2);
if (cause2=="USER_BUSY" or cause == "USER_BUSY" or cause == "NORMAL_TEMPORARY_FAILURE") then --sip:486 sip:503
session:execute("playback","ivr/ivr-im_sorry.wav");
session:execute("playback","ivr/ivr-user_busy.wav");
session:execute("log", "DEBUG HANGUP: User Busy");
if(calling_card~="1") then session:execute("hangup",486); end
elseif (cause == "NO_USER_RESPONSE" or cause2== "NO_USER_RESPONSE" or cause=="NO_ANSWER" or cause=="RECOVERY_ON_TIMER_EXPIRE" or cause2=="RECOVERY_ON_TIMER_EXPIRE") then--sip:480 / sip:408
--@TODO: recovery on timer expire could be something else, but I'm not sure how to test ring time in this script.
session:execute("playback","ivr/ivr-im_sorry.wav");
session:execute("playback","ivr/ivr-no_user_response.wav");
session:execute("log", "DEBUG HANGUP: No Response");
if(calling_card~="1") then session:execute("hangup",480); end
elseif (cause == "NORMAL_CLEARING" or cause == "SUCCESS") then --sip:200
session:execute("log", "DEBUG HANGUP: Normal Clearing.");
elseif (cause == "sip:999") then
session:execute("playback","ivr/ivr-invalid_number_format.wav");
session:execute("log", "DEBUG HANGUP: Invalid format according to my script");
dialed = session:getVariable("dialed");
session:say(dialed, "en", "number", "iterated");
session:streamFile("ivr/ivr-please_check_number_try_again.wav");
if(calling_card~="1") then session:execute("hangup",484); end
else
session:streamFile("ivr/ivr-call_cannot_be_completed_as_dialed.wav");
if(calling_card=="1") then
dialed = session:getVariable("dialed");
session:execute("log", "DEBUG playback number dialed: "..dialed);
session:say(dialed, "en", "number", "iterated");
end
session:streamFile("ivr/ivr-please_check_number_try_again.wav");
session:execute("log", "DEBUG HANGUP: "..cause.." Other, call cannot be completed as dialed");
if(calling_card~="1") then session:execute("hangup",484); end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment