Bookmarks to sections about IVR4Line on this page:
FIRST: Make sure to have your wave files into the same directory as the sample. If your device does not support 8kHz, 16bit, Mono format, be sure to get other formats from our web site "working with wave files" page.
Each line tab will allow you select a device from the dropdown combobox. You can create a one line Interactive Voice System if you only have one device, or if you have a multi-port line device such as a dialogic card, or multiple devices like 2 or more voice modems, you can see how to use TeleTools to create an IVR that can handle hundreds of simultaneous callers.
Select your device(s) and then activate them by checking the Active checkbox. Press the TeleScope button for each of the lines to popup our powerful testing, prototyping, diagnostic and logging tool that will allow you to monitor and even alter and work with the call progress on each line.
Now simply call into the lines you have activated and listen for the wave greeting. You will be able to press DTMF digits to play different messages based on your selections while the TeleScope logs show you exactly what is happening.
The etPlay and etRecord TeleScopes will show you what is going on with wave files and even the details of the wave format and position. You could use these methods and properties to allow precise positioning of a wave file to allow you to pause, stop, rewind, or even break one wave file up into component parts to play your custom message. TeleTools makes programming complex applications like IVR's a snap. Using SAPI, you can even play dynamic Text-To-Speech (TTS) messages as well as recorded wave files. See our main samples page for more samples and information.
For Use TeleTools v3.7
The etLine.Call.Tag property and etLine.OnDigitReceived event are utilized to create a simple "State Machine". See the etLine1.OnDigitReceived event handler routine for more information.
In the Form_Load event handler, a number of global variables are initialized. For each page in the tab control, SetControls is called to make the local Controls variable point to correct controls and initialize the ComboDevice(X) and the etLine(X) control to point to the corresponding device. (e.g. On the first page, the first TAPI line device is selected; on the second page, the second TAPI line device is selected, and so forth.) If there are fewer than four available telephony devices, the pages that are not needed are hidden. In the play and record status fields, the SetPlayRecordDevices routine is called to set the play and record devices associated with the TAPI line device.
Here in Form_Load is where we also load the wave files from disk and place them in buffers. Here is the code that does the work:
etPlay1.Source.BufferLoadFromFile("filename") ' loads a wave file from disk
In the even handler for the CheckActive(X).OnClick events of the CheckActive(X) controls, if the control is currently checked, etPlay(X).Device.Active is checked (validated) to see if a wave file is currently playing, if it is, then it is stopped by setting etPlay(X).Device.Active = False. etRecord(X).Device.Active is also checked and stopped if necessary. If the etLine(X).Call.Active property is True then it is set to False, this will cause the etLine(X).Call.Hangup method to be called. The line device is deactivated by setting the property etLine(X).Device.Active = FALSE.
If the CheckActive(X) control is currently unchecked, the TAPI line device is activated by setting etLine(X).Device.Active to True. If the error LINEERR_INVALIDMEDIAMODE is returned when activating the line device, the device is probably not 100% TAPI compliant. The etLine(X).Device.MediaModes.Active is set to LINEMEDIAMODE_DATAMODEM and etLine(X).Device.Active is once again set to True. We are assuming that the device is a modem that it does not support the voice features. Therefore we attempt to activate the modem in data mode. The program will not work properly in this mode. If you have a voice modem, but it is only being reported as a datamodem, please check the help file or web page for information about "working with modems".
Once the etLine(X).Device has been dealt with, the SetPlayRecordDevices subroutine is called to update the etRecord(X) and etPlay(X) devices to work with the current etLine(X) device settings.
If the property etLine(X).TAPI.TSP contains the string "Universal Modem Driver" then the property etPlay(X).Volume.Enabled is set to false because voice modems do not support the volume features.
In the ComboDevice(X).OnChange events of the ComboDevice(X) controls the etLine(X).Device.Active property is checked to see if the current device is active, if so then CheckActive(X) is set to false causing the device to be deactivated. The etLine(X).Device.ID is set to the index value of the device chosen in the combo box. In this way, we let you select, change and activate any of the Telephony devices whose TSP is listed in Windows.
In the etLine(X).OnConnected events of the etLine(X) controls. The property etLine(X).Call.MonitorDigits.Active property is set to True to begin monitoring for digits. The buffers are played with the following code for each of the controls:
etPlay.Source.Buffer.Handle := giBufferForThisWave;
' gets our handle to memory for the wave audio
The etPlay(X).Device.Loop property is set to false so that this file will play only once.
See the etPlay1Done event to find out what happened when a wave file is finished playing.
In etLine(X).OnDigitsReceived event handlers of the etLine(X) controls, the etPlay(X).Device.Active property is set to False to stop any wave files from playing. If an error occurs then the call is hung up by calling the method etLine(X).Call.Hangup. The etLine(X).Call.Tag property is then inspected and the correct action is taken based on the logic explained below.
If the Tag indicates that the line is currently recording (etLine(X).Call.Tag = TAG_RECORDING), then the recoding is stopped by setting etRecord(X).Device.Active = False. The file is then replayed by setting the etPlay.Source.BufferHandle property. If there is an error, we try to play using direct file access instead of buffers by setting etPlay.Source.BufferActive = False and then setting etPlay(X).Source.FileName to the value in etRecord(X).Source.FileName. The etLine(X).Call.Tag property is set to TAG_WAVEPLAY, which tells the application to play the wave file at the end of this routine. If an error occurred when setting etRecord(X).Device.Active = False, then the DisplayRecordError routine is called.
If menu was playing when the user pressed a key (etLine(X).Call.Tag = TAG_MENU), we respond to the pressed key as follows:
If the etLine(X).Call.Tag property has the value of TAG_MENU or TAG_WAVEPLAY then the file in the etPlay(X).Source.Buffer will be played.
In the OnDisconnected event handler, if the etPlay1.Device.Active property is True, then a wave file is currently playing and must be stopped by setting etPlay1.Device.Active = False. The etLine1.Call.Hangup method is called to hang up the call.
If the Count parameter in the OnRing event handler is greater than 2, then the etLine(X).Call.Answer method is called to answer the call. This is how we automatically answer the call after 3 rings.
In the OnDone event handler, if the property etLine(X).Call.State is equal to LINECALLSTATE_CONNECTED, then the call is still connected, and if the etPlay(X).Device.Loop property is False, then the menu wave files will be played next.
The OnClose Event. The etRecord(X).Device.Active and etPlay(X).Device.Active properties are set to False for all lines. This causes all recording and play to stop. The etLine(X).Call.Hangup method is called for each line which, causes all calls to hang up. The etLine(X).Device.Active property are set to False for all line device causing all devices to be deactivated.
The subroutine SetPlayRecordDevices sets the ID's for the play and record devices associated with your line devices. This is done by evaluating the properties etLine(X).WavePlay.Available and etLine(X).WaveRecord.Available, which will be True if Play or Record is supported and False if they are not. etPlay(X).Device.ID is set to etLine(X).WavePlay.ID and etRecord(X).Device.ID is set to etLine(X).WaveRecord.ID in order to select the wave devices associated to the line device. The LabelPlayDevice(X) control is updated with the etPlay(X).Device.Name and LabelRecordDevice(X) control is updated with the etRecord(X).Device.Name
CommandTeleScope(X).OnClick events of the CommandTeleScope(X) controls: This button causes the TeleScope.Visible properties to be toggled for the etLine(X), etPlay(X) and etRecord(X) controls. This causes the TeleScopes to be displayed or hidden.
The controls below containing (X) should be set with the name of the control ending in a digit (‘X’) corresponding to the line it’s associated with. For example for line 1, the CheckActive control would be CheckActive(1).
April 29, 2003