JavaScript.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Session Methods
  2. =======================================
  3. session.streamFile
  4. Usage:
  5. session.streamFile(file, timer, callback);
  6. file = Path to the file to play (ie /tmp/file.wav)
  7. timer = Timer to use for async mode. (optional)
  8. callback = Which function to fire when a dtmf digit is pressed. (optional)
  9. Callback return values and meanings:
  10. seek:ms - +1000 or -1000 will seek 1000ms forward or backwards, seek 0 will start the file over.
  11. speed: - +1,-1 or 0 for normal speed. (valid ranges are +1,+2, 0 or -1,-2)
  12. pause: - toggles pause and play modes on the file.
  13. You can also return arbitrary values and act on them as you
  14. wish. In our example we return "hangup" when the caller
  15. press the * key on the keypad.
  16. Example:
  17. function on_dtmf(digits)
  18. {
  19. if (digits == "3") {
  20. return "seek:+1000";
  21. }
  22. if (digits == "1") {
  23. return "seek:-1000";
  24. }
  25. if (digits == "*") {
  26. return "hangup";
  27. }
  28. }
  29. session.answer();
  30. while(session.ready()) {
  31. return_value = session.streamFile("/tmp/demo.wav", "", "on_dtmf");
  32. if (return_value == "hangup") {
  33. session.hangup(); // or break;
  34. }
  35. }
  36. To Document(these are in mod_spidermonkey already and just need
  37. documentation and examples):
  38. Methods:
  39. session.recordFile
  40. session.speak
  41. session.getDigits
  42. session.answer
  43. session.ready
  44. session.waitForAnswer
  45. session.hangup
  46. session.execute
  47. Properties:
  48. session.name
  49. session.state
  50. session.dialplan
  51. session.caller_id_name
  52. session.caller_id_num
  53. session.network_addr
  54. session.ani
  55. session.ani2
  56. session.destination
  57. Methods:
  58. DB.exec
  59. DB.next
  60. DB.fetch
  61. DB.prepare
  62. Properties
  63. DB.path
  64. Methods:
  65. teletone.generate
  66. teletone.onDTMF
  67. teletone.addTone
  68. Properties:
  69. teletone.name
  70. Other functions:
  71. console_log
  72. include
  73. email
  74. bridge
  75. apiExecute
  76. If you have CURL installed:
  77. fetchURLHash
  78. fetchURLFile