Advertisement
Guest User

lua IVR

a guest
Oct 16th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | None | 0 0
  1. ivr_def = {
  2.     ["main"]                = undef,
  3.     ["name"]                = "demo_ivr_lua",
  4.     ["greet_long"]          = "ivr/ivr-that_was_an_invalid_entry.wav",
  5.     ["greet_short"]         = "ivr/ivr-that_was_an_invalid_entry.wav",
  6.     ["invalid_sound"]       = "ivr/ivr-that_was_an_invalid_entry.wav",
  7.     ["exit_sound"]          = "voicemail/vm-goodbye.wav",
  8.     ["confirm_macro"]       = "",
  9.     ["confirm_key"]         = "",
  10.     ["tts_engine"]          = "flite",
  11.     ["tts_voice"]           = "rms",
  12.     ["confirm_attempts"]    = "3",
  13.     ["inter_digit_timeout"] = "2000",
  14.     ["digit_len"]           = "4",
  15.     ["timeout"]             = "10000",
  16.     ["max_failures"]        = "3",
  17.     ["max_timeouts"]        = "2"
  18. }
  19.  
  20. -- top is an object of class IVRMenu     ["invalid_sound"]       = "ivr/ivr-that_was_an_invalid_entry.wav",
  21. -- pass in all 16 args to the constructor to define a new IVRMenu object
  22. top = freeswitch.IVRMenu(
  23.     ivr_def["main"],
  24.     ivr_def["name"],
  25.     ivr_def["greet_long"],
  26.     ivr_def["greet_short"],
  27.     ivr_def["invalid_sound"],
  28.     ivr_def["exit_sound"],
  29.     ivr_def["confirm_macro"],
  30.     ivr_def["confirm_key"],
  31.     ivr_def["tts_engine"],
  32.     ivr_def["tts_voice"],
  33.     ivr_def["confirm_attempts"],
  34.     ivr_def["inter_digit_timeout"],
  35.     ivr_def["digit_len"],
  36.     ivr_def["timeout"],
  37.     ivr_def["max_failures"],
  38.     ivr_def["max_timeouts"]
  39. );
  40.  
  41. -- bindAction args = action, param, digits
  42. -- The following bindAction line is the equivalent of this XML from demo_ivr in ivr.conf.xml
  43. -- <entry action="menu-exec-app" digits="2" param="transfer 9996 XML default"/>
  44. top:bindAction("menu-exec-app", "transfer 9996 XML default", "2");
  45. top:bindAction("menu-exec-app", "transfer 9999 XML default", "3");
  46. top:bindAction("menu-exec-app", "transfer 9991 XML default", "4");
  47. top:bindAction("menu-exec-app", "bridge sofia/${domain}/
  48. 888 at conference.freeswitch.org", "1");
  49. top:bindAction("menu-exec-app", "transfer 1234*256 enum", "5");
  50. top:bindAction("menu-sub", "demo_ivr_submenu","6");
  51. top:bindAction("menu-exec-app", "transfer $1 XML features", "/^(10[01][0-9])$/");
  52. top:bindAction("menu-top", "demo_ivr_lua","9");
  53.  
  54. -- This hash defines the main IVR sub-menu. It is equivalent to the <menu name="demo_ivr_submenu" ... > lines in ivr.conf.xml
  55. ivr_sub_def = {
  56.     ["main"]                = undef,
  57.     ["name"]                = "demo_ivr_submenu_lua",
  58.     ["greet_long"]          = "phrase:demo_ivr_sub_menu",
  59.     ["greet_short"]         = "phrase:demo_ivr_main_sub_menu_short",
  60.     ["invalid_sound"]       = "ivr/ivr-that_was_an_invalid_entry.wav",
  61.     ["exit_sound"]          = "voicemail/vm-goodbye.wav",
  62.     ["confirm_macro"]       = "",
  63.     ["confirm_key"]         = "",
  64.     ["tts_engine"]          = "flite",
  65.     ["tts_voice"]           = "rms",
  66.     ["confirm_attempts"]    = "3",
  67.     ["inter_digit_timeout"] = "2000",
  68.     ["digit_len"]           = "4",
  69.     ["timeout"]             = "15000",
  70.     ["max_failures"]        = "3",
  71.     ["max_timeouts"]        = "2"
  72. }
  73.  
  74. -- sub_menu is an object of class IVRMenu
  75. -- pass in all 16 args to the constructor to define a new IVRMenu object
  76. sub_menu = freeswitch.IVRMenu(
  77.     ivr_sub_def["main"],
  78.     ivr_sub_def["name"],
  79.     ivr_sub_def["greet_long"],
  80.     ivr_sub_def["greet_short"],
  81.     ivr_sub_def["invalid_sound"],
  82.     ivr_sub_def["exit_sound"],
  83.     ivr_sub_def["confirm_macro"],
  84.     ivr_sub_def["confirm_key"],
  85.     ivr_sub_def["tts_engine"],
  86.     ivr_sub_def["tts_voice"],
  87.     ivr_sub_def["confirm_attempts"],
  88.     ivr_sub_def["inter_digit_timeout"],
  89.     ivr_sub_def["digit_len"],
  90.     ivr_sub_def["timeout"],
  91.     ivr_sub_def["max_failures"],
  92.     ivr_sub_def["max_timeouts"]
  93. );
  94.  
  95. -- Bind the action "menu-top" to the * key
  96. sub_menu:bindAction("menu-top","demo_ivr_lua","*");
  97. --sub_menu:execute(session,"demo_ivr_submenu_lua");
  98.  
  99. -- Run the main menu
  100. top:execute(session, "demo_ivr_lua");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement