README.externalivr 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Asterisk External IVR Interface
  2. -------------------------------
  3. If you load app_externalivr.so in your Asterisk instance, you will
  4. have an ExternalIVR() application available in your dialplan. This
  5. application implements a simple protocol for bidirectional
  6. communication with an external process, while simultaneous playing
  7. audio files to the connected channel (without interruption or
  8. blocking).
  9. The arguments to ExternalIVR() consist of the command to execute and
  10. any arguments to pass to it, the same as the System() application
  11. accepts. The external command will be executed in a child process,
  12. with its standard file handles connected to the Asterisk process as
  13. follows:
  14. stdin (0) - DTMF and hangup events will be received on this handle
  15. stdout (1) - Playback and hangup commands can be sent on this handle
  16. stderr (2) - Error messages can be sent on this handle
  17. The application will also create an audio generator to play audio to
  18. the channel, and will start playing silence. When your application
  19. wants to send audio to the channel, it can send a command (see below)
  20. to add file(s) to the generator's playlist. The generator will then
  21. work its way through the list, playing each file in turn until it
  22. either runs out of files to play, the channel is hung up, or a command
  23. is received to clear the list and start with a new file. At any time,
  24. more files can be added to the list and the generator will play them
  25. in sequence.
  26. While the generator is playing audio (or silence), any DTMF events
  27. received on the channel will be sent to the child process (see
  28. below). Note that this can happen at any time, since the generator,
  29. the child process and the channel thread are all executing
  30. independently. It is very important that your external application be
  31. ready to receive events from Asterisk at all times (without blocking),
  32. or you could cause the channel to become non-responsive.
  33. If the child process dies, ExternalIVR() will notice this and hang up
  34. the channel immediately (and also send a message to the log).
  35. DTMF (and other) events
  36. -----------------------
  37. All events will be newline-terminated strings.
  38. Events send to the child's stdin will be in the following format:
  39. tag,timestamp[,data]
  40. The tag can be one of the following characters:
  41. 0-9: DTMF event for keys 0 through 9
  42. A-D: DTMF event for keys A through D
  43. *: DTMF event for key *
  44. #: DTMF event for key #
  45. H: the channel was hung up by the connected party
  46. Z: the previous command was unable to be executed (file does not
  47. exist, etc.)
  48. T: the play list was interrupted (see below)
  49. D: a file was dropped from the play list due to interruption (the
  50. data element will be the dropped file name)
  51. F: a file has finished playing (the data element will be the file
  52. name)
  53. The timestamp will be 10 digits long, and will be a decimal
  54. representation of a standard Unix epoch-based timestamp.
  55. Commands
  56. --------
  57. All commands must be newline-terminated strings.
  58. The child process can send commands on stdout in the following formats:
  59. S,filename
  60. A,filename
  61. H,message
  62. O,option
  63. The 'S' command checks to see if there is a playable audio file with
  64. the specified name, and if so, clear's the generator's playlist and
  65. places the file onto the list. Note that the playability check does
  66. not take into account transcoding requirements, so it is possible for
  67. the file to not be played even though it was found. If the file cannot
  68. be found, a 'Z' event (see above) will be sent to the child. If the
  69. generator is not currently playing silence, then T and D events will
  70. be sent to the child to signal the playlist interruption and notify
  71. it of the files that will not be played.
  72. The 'A' command checks to see if there is a playable audio file with
  73. the specified name, and if so, adds it to the generator's
  74. playlist. The same playability and exception rules apply as for the
  75. 'S' command.
  76. The 'H' command stops the generator and hangs up the channel, and logs
  77. the supplied message to the Asterisk log.
  78. The 'O' command allows the child to set/clear options in the
  79. ExternalIVR() application. The supported options are:
  80. autoclear/noautoclear:
  81. Automatically interrupt and clear the playlist upon reception
  82. of DTMF input.
  83. Errors
  84. ------
  85. Any newline-terminated output generated by the child process on its
  86. stderr handle will be copied into the Asterisk log.