home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / voice2.zip / V_FOD.CMD < prev    next >
OS/2 REXX Batch file  |  1997-05-22  |  13KB  |  302 lines

  1. /* V_FOD.CMD - Voice/Fax Answer Script for FaxWorks/PMfax (REXX) */
  2. /* 
  3.                   Keller Group Inc.  May 22, 1997
  4.    You may freely use or modify this script for use with licensed
  5.         products which are developed by Keller Group Inc.
  6.       For new scripts or to share your scripts with others,
  7.                  see http://www.kellergroup.com
  8. */
  9. /*******************************************************************
  10. V_FOD.CMD - Fax-on-demand with extras (for Voice/fax Modems)
  11.  
  12. For use with any of the following Keller software configurations:
  13.         Stand-alone (single-line or multiline)
  14.         LAN (single-line or multiline server, Shared or Private Mode)
  15.  
  16. Supported features:
  17.     Both one-call and two-call fax-on-demand (FOD)
  18.     Interactive fax response (generate data and fax it on-the-fly)
  19.     Both text file and fax image file support
  20.     Voice-on-demand (VOD)
  21.     Drag/drop creation of FOD/VOD document library
  22.     Voice announcement 
  23.     Voice messaging from caller
  24.     Fax receiving from caller
  25.     Can be customized to support call blocking, different
  26.        features on different lines of a multiline system or
  27.        different extensions in a DID system, internet faxing, etc.
  28.     Full source code in REXX - modify as needed
  29.  
  30. DESCRIPTION:
  31. -----------
  32. This script plays a greeting message and asks the user to select 1
  33. (fax-on-demand), 2 (voice message), 3 (send a fax), 4 (hear
  34. announcement message), or 5 (replay the greeting message).
  35.  
  36. If the call is from a fax device and your fax hardware detects the
  37. caller's fax (CNG) tones, the script automatically receives the fax.
  38.  
  39. If a caller does not enter any key (such as if calling from a phone
  40. which doesn't support touch tones), the script automatically goes to
  41. "please leave a voice message" mode.
  42.  
  43. This script does much more than just "fax-on-demand" since it also
  44. supports "voice-on-demand" (playing user-selected voice message
  45. files) and "text-on-demand" (converting user-selected text files to
  46. fax and faxing them).  It also demonstrates how you can execute your
  47. own programs to dynamically gather data (such as from your database)
  48. and send it as a fax document.  So it's really a powerful "document
  49. on demand" system that you can customize to meet your needs.
  50.  
  51. USAGE INSTRUCTIONS:
  52. ------------------
  53. You must be using the program with supported voice/fax hardware to
  54. use this script.  Consult the README.DOC file for tested voice/fax
  55. hardware and recommended configuration settings for your hardware.
  56. Before using this script, first test your system with our built-in
  57. voice answering machine feature by enabling "Voice" and setting the
  58. "Answer script" to * (an asterisk character) on the Voice page of the
  59. Settings notebook.  If you are using supported voice/fax hardware
  60. with the proper configuration settings, you can then use
  61. "Fax/Receive/All calls" mode to answer calls, play the outgoing
  62. message (OGM), and record a voice message (or receive a fax).
  63.  
  64. Then, to change to this advanced script, specify the full pathname of
  65. this file in the "Answer script" field on the Voice page of the
  66. settings notebook.
  67.  
  68. NOTE: The script expects to find the LIB_FOD.CMD file and its Wave
  69. audio files in the fax program (EXE) directory.  The script also uses
  70. Wave files from the c:\mmos2\sounds directory for special effects.
  71.  
  72. SCRIPT VARIABLES:
  73. ----------------
  74. The following script variable is used by this script.  Script
  75. variables are set on the Voice page of the Settings Notebook.
  76.  
  77.     FODDIR - pathname of directory which contains "on-demand"
  78.     files, including the trailing \ character.  If not specified,
  79.     the files are assumed to be in the fax data (fax.log)
  80.     directory which allows you to select IDs from the program's
  81.     log for testing the system.
  82.  
  83. VOICE PROMPT FILES:
  84. ------------------
  85. The script expects to find the following Wave audio files in the fax
  86. program (EXE) directory.  The script also uses Wave files from the
  87. c:\mmos2\sounds directory for special effects.
  88.  
  89. To record or modify your own voice prompt files, use your OS/2
  90. Multimedia microphone and record voice prompts using the "Fax/New
  91. message" command then save them to a .WAV file with the "Fax/Save
  92. file/Wave" command.  You can also use the OS/2 Digital Audio program
  93. to record, save, edit and modify the Wave files (be sure to use
  94. "Type" of Mono, 8-bit, 11.025 kHz).
  95.  
  96.     GREETFOD.WAV - Short: "Enter selection."
  97.     Long: "Thank you for calling.  To order fax on demand
  98.     documents press 1, to leave a voice message press 2, to send
  99.     us a fax press 3, to hear our announcement press 4, or to
  100.     repeat this message press 5." 
  101.  
  102.     ANNOUNC.WAV - Short: "No announcement."
  103.     Long: "Our annoucement for this week is...."
  104.  
  105.     ENTR_MSG.WAV - Short: "Enter message, then press # key."
  106.     Long: "Please leave your message at the beep.  Press # key to end."
  107.  
  108.     ENTR_DOC.WAV - Short: "Enter document number and # key, or
  109.     press the # key if done."
  110.     Long: "Please enter the document number followed by the # key,
  111.     or press the # key if done.  To receive an index of available
  112.     documents, enter document 1000."
  113.  
  114.     HOW_FAX.WAV - Short: "Enter 1 if calling from fax machine, 2
  115.     if not."
  116.     Long: "If you are calling from your fax machine and are ready
  117.     to receive the fax press 1, to send the fax to a different
  118.     number press 2." 
  119.  
  120.     ENTR_FAX.WAV - Short: "Enter fax number and # key."
  121.     Long: "Please enter your fax number followed by the # key,
  122.     including 1 and area code if this is not a local call." 
  123.  
  124.     NO_FILE.WAV - Short: "File not found."
  125.     Long: "That document was not found, please try again."
  126.  
  127.     WAIT.WAV - Short: "Please wait."
  128.     Long: "Please wait while we process your request."
  129.  
  130.     THANKYOU.WAV - Short: "Thank you."
  131.  
  132.  
  133. FAX/VOICE/TEXT-ON-DEMAND DOCUMENTS:
  134. ----------------------------------
  135. This script allows the user to enter document numbers to select one
  136. or more documents.  Each document can be a fax, text or voice message
  137. document.  When voice documents are selected, they are played to the
  138. caller.  When fax and text documents are selected, they are gathered
  139. as a list and then either faxed to the caller on this current call
  140. ("one-call" fax-on-demand - if caller called from a fax machine) or
  141. faxed to a number which the caller enters ("two-call" fax-on-demand).
  142.  
  143. The program's standard document file name format is used for the
  144. "on-demand" documents (FX000001.FAX for fax documents, FX000001.TXT
  145. for text documents, FX000001.MSG for voice message documents).  Any
  146. fax, voice or text item that can appear in the log can be used as an
  147. "on-demand" document.  You can create the documents in many different
  148. ways (faxing to the program, printing through the FxPrint printer
  149. driver, using the program's editing tools, recording voice messages
  150. using Fax/New message or the answering machine features, etc.).
  151.  
  152. If the FODDIR script variable is not set, then this script can use
  153. the documents from the log and the "document number" is the "ID"
  154. number in the program's log display ("Fax/Open log" command).
  155.  
  156. If the FODDIR script variable is set to a different directory, then
  157. this script uses the documents which are found in that directory.
  158. For actual use, you will usually want to do this so that you can
  159. control the document numbers yourself.  For example, you may wish to
  160. have an "index fax" as document 1000 (file FX001000.FAX) so that
  161. callers can order a list of all available documents, then have
  162. different categories of documents as document 1100, 1101, 1200,
  163. 1201, etc.  This is easy to do using your choice of techniques:
  164.  
  165.     1) DRAG/DROP - Create a folder, drag (to move) or Ctrl-drag
  166.     (to copy) the documents from the log to your folder, and use
  167.     direct editing (Alt-Click) to edit the file names to use your
  168.     desired ID values.  Set the FODDIR script variable to the
  169.     pathname of the folder's directory (including trailing \).
  170.  
  171.     2) COMMAND LINE - Create a directory, then copy the desired
  172.     files from the log directory to your desired file names in
  173.     your directory (or use the Fax/Save file command in the fax
  174.     program).  Set the FODDIR script variable to the pathname of
  175.     the directory's pathname (including trailing \ character).
  176.  
  177. The script uses ID 9999 as a special case to demonstrate how you can
  178. dynamically call another program to generate text, convert the text
  179. to a fax and send the fax to the caller.  For this demonstration, we
  180. simply use the OS/2 DIR command, but you could change this to do
  181. something more interesting (a database query, etc.).
  182.  
  183. TO MODIFY THE SCRIPT:
  184. --------------------
  185. The script is REXX and uses calls from the Keller REXX API which are
  186. automatically loaded into the OS/2 REXX environment by the retail
  187. versions of Keller's fax products (version 3.0 and later).  See the
  188. Reference Manual for documentation of the FxRx and FxLn calls.  You
  189. may modify the script as desired, and then use it as the "Answer
  190. script" with Keller fax software products.
  191.  
  192. TO USE WITH MULTILINE VERSIONS:
  193. ------------------------------
  194. This script can be used with multiline versions of Keller fax
  195. software.  The LAN and Standalone Multiline product versions can
  196. accept multiline upgrade options up to 96 lines per CPU, and the
  197. Multiple Fax Server Facility supports multiple cooperating fax
  198. servers for additional capacity.  Please contact the publisher of
  199. your Keller fax software for pricing and details.
  200.  
  201. All lines are handled identically by this script, so calls can be
  202. received on any of your "receive" lines.  If you prefer to have
  203. different lines handled differently, you can modify the script to
  204. test the LID variable.  For example, to have line 1 immediately jump
  205. to the "please enter your message" prompt, you could add a line like
  206. the following after the "call FxLnInit" line in the script: "if LID =
  207. 1 then signal voice" where "voice" is a label in the script.
  208.  
  209. When using a multiline version of Keller fax software, you can easily
  210. adjust the send/receive settings on the Ports page in the Settings
  211. notebook to determine how the lines are used.  For example, to direct
  212. the two-call fax-on-demand outbound faxing to special outbound lines
  213. so that your inbound lines will remain available for callers, you can
  214. set the inbound lines to "Receive" and the outbound lines to "Send"
  215. or "Send/Receive".  Alternatively, if you set your inbound lines to
  216. "Send/Receive" and your outbound lines to "Send", the software will
  217. first try to use the "Send" lines for outbound faxing but will use a
  218. "Send/Receive" line if all "Send" lines are currently in use.
  219.  
  220. *******************************************************************/
  221.  
  222. call FxLnInit
  223.  
  224. if FODDIR = 'FODDIR'        /* if not set, get docs in log dir */
  225.   then FODDIR = FxRxPath( 'LOG' )
  226.  
  227. VOXDIR = FxRxPath( 'EXE' )    /* get voice prompts from exe dir */
  228. LIBDIR = FxRxPath( 'EXE' )    /* get REXX subroutines from exe dir */
  229. FODPROCEDURE = LIBDIR||'lib_fod.cmd'  /* use this external procedure */
  230.  
  231. hello:
  232.   LREC. = ""                /* be sure this is clean */
  233.   call FxLnMsg 'Greeting'        /* show this in status window */
  234.  
  235.   call FxLnPlay VOXDIR||'GREETFOD.WAV'    /* play the greeting prompt */
  236.     if result = 'NOTOK' then signal byebye
  237.     if result = 'FAX' then signal fax
  238.     if result = 'DATA' then signal data
  239.  
  240.   call FxLnMsg 'User selection'
  241.   call FxLnDtmf 1, 15, 'digit'           /* get user selection */
  242.     if result = 'NOTOK' then signal byebye
  243.     if result = 'FAX' then signal fax
  244.     if result = 'DATA' then signal data
  245.     if result <> 'DTMF' then signal voice  /* if no key entered... */
  246.   select
  247.     when digit = 1 then signal fod       /* go to key selection  */
  248.     when digit = 2 then signal voice
  249.     when digit = 3 then signal fax
  250.     when digit = 4 then signal announce
  251.     when digit = 5 then signal hello
  252.     otherwise signal voice
  253.   end
  254.  
  255. voice:                    /* take a message and hangup */
  256.   call FxLnMsg "Record Msg"
  257.   call FxLnPlay VOXDIR||'ENTR_MSG.WAV'
  258.     if result = 'NOTOK' then signal byebye
  259.     if result = 'FAX' then signal fax
  260.     if result = 'DATA' then signal data
  261.   call FxLnTone 1850
  262.     if result = 'NOTOK' then signal byebye
  263.   call FxLnDtmf    /* flush dtmf buffer */
  264.   call FxLnRecord
  265.     if result = 'NOTOK' then signal byebye
  266.     if result = 'FAX' then signal fax
  267.     if result = 'DATA' then signal data
  268.     /* Caller can press key or hangup to end message */
  269.   call FxLnTone 1850, 1850, 1850
  270.   signal out
  271.  
  272. fax:                    /* receive fax and hangup */
  273.   call FxLnReceive
  274.   signal out
  275.  
  276. data:                    /* report data call, hangup*/
  277.   call FxLnMsg 'Data call, oh well...'
  278.   LREC.!Status = '*Data!'   /* log status of call */
  279.   signal out
  280.  
  281. announce:                /* play annoucement, restart */
  282.   call FxLnMsg "Announcement"
  283.   call FxLnPlay VOXDIR||'ANNOUNC.WAV'
  284.     if result = 'NOTOK' then signal byebye
  285.   signal hello
  286.  
  287. fod:                    /* "document-on-demand" ... */
  288.   /* call the external FOD procedure in LIBDIR directory */
  289.   FODPARAMS = 'FODDIR, VOXDIR'
  290.   interpret 'call' "'"||FODPROCEDURE||"'" FODPARAMS
  291.   /* jump to the label that matches the return value */
  292.   signal value result
  293.  
  294. byebye:                    /* called for error cases */
  295.   LREC.!Status = ''            /* don't log anything */
  296.   call FxLnPlay 'c:\mmos2\sounds\BOO.wav'
  297.   signal out
  298.  
  299. out:                    /* clean up and quit */
  300.   call FxLnTerm
  301.   exit
  302.