etDialAnswer Sample Program

TeleTools

The DialAnswer sample program demonstrates how the etLine, etPhone, etPlay, and etRecord controls can be used together. It allows the user to both call out (Dial) and receive incoming calls (Answer) , and track the various events fired in the process by the output in the log box. The user can:

  • Select from all available telephony devices

  • Test the selected device for a dial tone

  • Play files when a call is connected

  • Cause those files to loop continuously or to only play once

  • Modify the volume and gain on the speakerphone, if attached

  • Record all or part of a call to a wave file.

 

Click here for more information about Detecting Automated Answering Devices.

Requirements
Using This Sample Program
Download this Sample Program 
How this Sample Program Works
Source Code
Release Notes

Development Environment Technical Information
Telephony Hardware Technical Information

 

Requirements

  • You can use this sample with any of the following Editions of TeleTools v37
    • TeleTools Standard

    • TeleTools Professional

    • TeleTools Enterprise

  • Working telephone line

  • TAPI Telephony device such as a Hi-Phone, SST, Dialogic Card, PBX, voice modem, etc.

  • Installed TSP for the device

Using This Sample Program

When the etDialAnswer sample program starts you will need to select a telephony device from the list in the top/center then click the Active check box to begin using the device.

The TeleScope button allows you to display the TeleScopes for each of the TeleTools controls.

To make an outbound call put a number in the edit box adjacent to the Dial button then click it.  If the telephony  device supports detecting silence the etDialAnswer will attempt to detect of the answering party is a human or an answering machine. Click here for more information about Detecting Automated Answering Devices.

To answer an inbound call click the Answer button.  You will see information appear in the activity log when an inbound call is detected.  See the etAutoAnswer sample program to learn how answer inbound calls after a given number of rings.

When a call is complete click the "Hang up" button to disconnect the call.  Many devices will cause the etLine.OnDisconnected event to fire when the remote party hangs up.

Click the "Dialtone?" button to test for a dial tone.  Not all devices test for dial tone in the same manner.  This show only one method and may not work with your device.  Also see the etDialogicDial sample program.

Some devices support playing wave files over the phone line.  By clicking the "Play OnConnect" check box this program will play the wave file in the adjacent edit box when an inbound or outbound call is connected.   If the Loop check box is checked then the wave file will play again and again.  Not all devices support the loop feature,  for example you should not use this feature with Dialogic cards.

Some telephony devices support the TAPI Phone devices which provides access to the headset, handset and speakerphone features.  If the "PhoneDevice" check box is checked then you will see an icon that indicates the current status of the handset and the Speakerphone can be managed with the controls in right/center section.

Some devices allow you to record wave files from the phone line.  Hold down the Record button to create a wave file of the sound heard on the phone line.  When the button is released the wave file will be played over the phone line.

An activity log of the events, methods and properties is at the bottom of the screen.  Clicking the Clear button will clear the information.

Remember etDialAnswer only shows a small part of the power of ExceleTel TeleTools!  TeleScope is one of the most powerful programming tools for CTI and it is built into ExceleTel TeleTools.  With TeleScope you can access many of the features of TeleTools at run time as well as design time.  TeleScope will shorten your learning curve and aiding in solving problems once your application is deployed.  Be sure to take a closer look at ExceleTel TeleTools

Click here for more information about unique features found in TeleScope!

Download this Sample Program

For Use TeleTools v3.7

File

Purpose

EXE

Ready to run!

Borland C++ 4,5,6

Source code and wave files

Borland Delphi 5,6,7

Source code and wave files

Visual Basic 5,6

Source code and wave files

Visual Basic .NET

Source code and wave files

Visual C++ 6

Source code and wave files

PowerBuilder Souce code

Visual Fox Pro 6

Source code and wave files

Tell us what you need?

Click here and tell us what you need!

   

How this Sample Program Works

 

Control

Description

CheckBoxActive

Used to activate the TAPI Line device.

ComboBoxDevice

Used to select the TAPI line device.

ButtonTeleScopes

When clicked the TeleScope.Visible property for the etLine, etPhone, etPlay and etRecord controls are toggled to True or False causing the TeleScopes to be displayed or hidden.

ButtonDial

For dialing out bound calls.

EditPhoneNumber

Holds the phone number to be dialed.

ButtonAnswer

For answering in bound calls.

ButtonHangup

For hanging up all calls.

ButtonDialtone

Testing for dial tone.

CheckBoxPlayOnConnect

For indicating if the wave files is played when the etLine.OnConnected event fires.

EditWaveFile

The wave file to be played. See CheckBoxPlayOnConnect

CheckBoxLoop

Indicates if the wave file should loop.

CheckBoxPhone

Indicates if the etPhone device should be used.

ImageHandsetOffHook

ImageHandsetOnHook

Displays the status of the handset hookswitch for the etPhone.Device.ID.

GroupBoxSpeakerphone

Contains the controls for working with the etPhone speakerphone features.

RadioButtonSPOffHook

RadioButtonSPOnHook

Show the status and allows the state to be set for the etPhone.SpeakerphoneHookswitch

LabelSPVolume

Displays "Volume"

EditSPVolume

Holds the value of the etPhone.Speakerphone.Volume

ButtonSPVolumeApply

Updates the property etPhone.Speakerphone.Volume when pressed.

LabelSPGain

Displays "Gain"

EditSPGain

Holds the value of the etPhone.Speakerphone.Gain

ButtonSPGainApply

Updates the property etPhone.Speakerphone.Gain when pressed.

ButtonRecord

Records a wave file using the etRecord control while the button is held down.

ButtonClear

Clears the information in the Memo1 control

Memo1

Displays the log information.

etLine1

The etLine control

etPhone1

The etPhone control

etPlay1

The etPlay record

etRecord1

The etRecord control

TimerAutomatedAnsweringDevice

Timer used along with etLine.MonitorSilence to detect answering machines

 

Event Handler Routine

Description

CheckActive_Click

NOTE: You can click on any of these event handler routines to be taken right to the source code.

The “Active” checkbox is used to turn the selected line device on, when checked, or off, when not checked. If the control is checked, then the line device is activated by setting the property etLine1.Device.Active = TRUE; if not checked, then the line device is deactivated by setting the property etLine1.Device.Active = FALSE. 

When deactivating the line device, the TAPI phone device is first deactivated by setting the property etPhone1.Device.Active = FALSE. When the line device is inactive, the ButtonDial and ButtonDialTone controls are disabled. 

If there error LINEERR_INVALIDMEDIAMODE is returned when activating the line device, the device is probably not 100% TAPI-compliant. The etLine1.Device.MediaModesActive is set to LINEMEDIAMODE_DATAMODEM and etLine1.Device.Active is once again set to TRUE. We assume that the device is a modem that does not support the voice features, so we attempt to activate the modem in data mode. 

After successfully activating the line device, the ButtonDial and ButtonDialTone controls are enabled. If the CheckBoxPhone is checked and etLine1.Phone.Available = True, indicating that a TAPI phone device is available, then the TAPI phone device is activated by setting the property etPhone1.Device.Active = TRUE. If the property etLine1.TAPI.TSP contains the string "Universal Modem Driver", then the property etPlay1.Volume.Enabled is set to false because voice modems do not support the volume features. 

If the the TAPI line device supports playing wave files ( etLine1.WavePlay.Available = True), then controls CheckBoxPlayOnConnect, EditWaveFile, and CheckBoxLoop are enabled; otherwise they are disabled. 

The UpdatePhoneDisplay routine is called to enable or disable controls having to do with the speakerphone settings.

CheckLoop_Click

The etPlay1.Device.Loop property is set to the value this check box.

CheckPhone_Click If this is unchecked and etPhone1.Device.Active = True, then etPhone1.Device.Active is set to False. If it is checked and etLine1.Device.Active = True and etPhone1.Device.Active = False, then etPhone1.Device.Active is set to True. If an error occurs, then etPhone1.Device.Active remains False and this check box remains unchecked.

ComboDevice_Click

The etLine1.Device.Active property is checked to see if the current device is active. If so, then CheckBoxActive is set to false causing the device to be deactivated. The etLine1.Device.ID is set to the index value of the device chosen in the combo box. If no errors occurred, then the properties etLine1.Privilege.Monitor and etLine1.Privilege.Owner are set to true.

CommandAnswer_Click The etLine1.Call.Answer method is called then the etLine1.Error properties are tested for errors. Any error information is appended to the log edit box.

CommandClear_Click

The information in the Memo1 control is cleared.

CommandDial_Click The etLine1.Call.PhoneNumber property is set to the value in the EditPhoneNumber control then the etLine1.Call.Dial method is then called. If no errors occurred then the ButtonDial and ButtonDialtone controls are disabled and the ButtonHangup control is enabled.

CommandDialtone_Click

The property is set to etLine1.Call.PhoneNumber = “;W” which indicates to the telephony device to begin the dialing process although wait for a dial tone. The etLine1.Privilege.None and etLine1.Device.MediaModesActive properties are then tested to see if this device has the ability to make a voice call. The etLine1.Call.Dial method is then called. If successful, then then the etLine1.OnDialtone event fires. 

This method of checking for a dial tone may not work with all telephony devices. Not all Telephony Service Providers (TSP) and/or telephony devices support the "W" as a valid "dial-able" character. See the etLine.Call.PhoneNumber property for the list of dial-able characters.

CommandHangup_Click Prior to calling the etLine1.Call.Hangup method etPlay1.Device.Active is checked to see if a wave file is currently playing, if it is then it is stopped by setting etPlay1.Device.Active = False. etRecord1.Device.Active is also checked and stopped if necessary.

CommandRecord_MouseDown

As long as this button is held down, etRecord1 will record a wave file. etLine1.TAPI.TSP is checked to see if a Dialogic board is being used. If so, then the etRecord1.Source.Format.ID is set to use the wave format "uLaw8000 Hz, 8 bit, Mono". Otherwise, the default "PCM 8000 Hz, 16 bit, Mono" is used. etRecord.Source.Format.FileName is set to a valid path and file name. The correct wave audio device is selected by setting etRecord1.Device.ID to the value of the property etLine1.WaveRecord.ID. Recording is started by setting etRecord1.Device.Active to True.

CommandRecord_MouseUp When this button is released, etRecord1 will stop recording and etPlay1 will play the wave file that was just recorded. Recording is stopped by setting etRecord1.Device.Active = False. If etPlay1 is currently playing a wave file, then it is stopped. etPlay1.Source.FileName is set to the file that was just recorded. The correct wave audio device is selected by setting etPlay1.Device.ID to the value of the property etLine1.WavePlay.ID. Playing is started by setting etPlay1.Device.Active = True.

CommandSPGainApply_Click

The the property etPhone.Speakerphone.Gain is set to the value in the EditSPGain control. The event queue is allowed to be emptied allowing time for the speakerphone to adjust. The EditSPGain control is updated to match the speakerphone’s new gain setting.

CommandSPVolumeApply_Click The the property etPhone.Speakerphone.Volume is set to the value in the EditSPVolume control. The event queue is allowed to be emptied, allowing time for the speakerphone to adjust. The EditSPVolume control is updated to match the speakerphone’s new volume setting.

etLine1_OnBusy

When this occurs, the etLine1.Call.Hangup method is called.

etLine1_OnCallBegin This event is appended to the log edit box on-screen.

etLine1_OnCalledID

When the etLine.OnCalledID event fires the etLine1.Call.CalledID.Name and etLine1.Call.CalledID.Number property values are appended to the log.

etLine1_OnCallEnd This event is appended to the log edit box on-screen.

etLine1_OnCallerID

When the etLine1.OnCallerID event fires, the etLine1.Call.CallerID.Name and etLine1.Call.CallerID.Number property values are appended to the log.

etLine1_OnConnected

The etLine1.Call.Origin is checked to see if the call is inbound or outbound.

  • If this is an outbound call, then silence-monitoring will be used to test for an answering machine. TimerAutomatedAnsweringDevice is enabled, see TimerAutomatedAnsweringDeviceTimer. etLine1.Call.MonitorSilence.Duration is set to monitor for 1.5 seconds of silence and etLine1.Call.MonitorSilence.Active is set to True to begin monitoring for silence.
  • If it is an inbound call, then the wave file is played if CheckBoxPlayOnConnect.Checked is set to True. etPlay1.Source.FileName is set to the file in the EditWaveFile control. The correct wave audio device is selected by setting etPlay1.Device.ID to the value of the property etLine1.WavePlay.ID. Playing is started by setting etPlay1.Device.Active = True.

The Enabled property for several buttons is modified.

etLine1_OnConnectedID

When the etLine.OnConnectedID event fires, the etLine1.Call.ConnectedID.Name and etLine1.Call.ConnectedID.Number property values are appended to the log.

etLine1_OnDialing This event is appended to the log edit box on-screen.

etLine1_OnDialtone

When the etLine1.OnDialtone fires, the global State variable is checked to see if the ButtonDialtone button was clicked. If it was, then it is indicated in the log that the dial tone test was successful. Otherwise, it is simply indicated in that log that this event has fired.

etLine1_OnDigitReceived

If a wave file is currently playing, then it is stopped by setting etPlay1.Device.Active = False. If a wave play device is available, the wave file for the digit will be played. For example, if "1" is received, then etPlay1.Source.FileName will be set to "1" causing the wave file 1.wav to be played by setting etPlay1.Device.Active = True. There are no wave files for the following DTMF tones "*", "#", "A", "B", "C" or "D".

For an example of how to use the Tag parameter, see the etIVR4Line sample program.

etLine1_OnDisconnected

If ButtonDialtone had been clicked and this event occurs, then the etLine1.Call.DisconnectMode property is tested to see if the dial tone was detected. This may not work with some telephony devices because not all Telephony Service Providers (TSP) and/or telephony devices are capable of reporting a disconnect mode.

 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. If the etRecord1.Device.Active property is True then a wave file is currently recording and must be stopped by setting etRecord1.Device.Active = False.

 The etLine1.Call.Hangup method is called to hang up the call.

etLine1_OnError The log is updated to indicate that this event has fired.

etLine1_OnIdle

The ButtonDialtone and ButtonDial controls are enabled. The ButtonRecord, ButtonAnswer and ButtonHangup are disabled. 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. If the etRecord1.Device.Active property is True then a wave file is currently recording and must be stopped by setting etRecord1.Device.Active = False.

etLine1_OnOffering The ButtonAnswer control is enabled. The ButtonDialtone control is disabled.

etLine1_OnRedirectingID

The etLine1.Call.RedirectingID.Name and etLine1.Call.RedirectingID.Number property values are appended to the log.

etLine1_OnRedirectionID The etLine1.Call.RedirectionID.Name and etLine1.Call.RedirectionID.Number property values are appended to the log.

etLine1_OnRing

The log edit box is updated with a message.

etLine1_OnRingBack The log edit box is updated with a message.

etLine1_OnSilence

If the property etLine.Call.Origin indicates that this is an outbound call, then TimerAutomatedAnsweringDevice is disabled. Monitoring for silence is stopped by setting etLine1.Call.MonitorSilence.Active to False. The current time and the stored time are used to see if 2 seconds have passed since silence detection has been initiated. If silence was detected in less than 2 seconds then the call was probably answered by a human and not an answering machine.

 Answering machine detection in this manner can be reliable although you may have to modify the properties etLine1.MonitorSilence.Duration and TimerAutomatedansweringDevice.Duration.

etLine1_OnSpecialInfo The log edit box is updated with a message.

etPhone1_OnDigitDown

The log edit box is updated with a message.

etPhone1_OnDigitUp The log edit box is updated with a message.

etPhone1_OnError

The log is updated to indicate that this event has fired.

etPhone1_OnHandsetHookSwitch The current state for the etPhone1.HandsetHookSwitch properties are displayed in the log and the UpdatePhoneDisplay routine is called.

etPhone1_OnPhoneState

The etPhone1.OnPhoneState event is fired when the current state of the TAPI Phone device changes. The etPhone1.Device.State and etPhone1.Device.StateDetails property values are displayed in the log.

etPhone1_OnSpeakerphoneGain The etPhone1.OnSpeakerphoneGain event is fired when the gain for the speakerphone is adjusted. The etPhone1.Speakerphone.Gain property is displayed in the log. The EditSPGain control is updated with the new value of etPhone1.Speakerphone.Gain.

etPhone1_OnSpeakerphoneHookSwitch

The etPhone1.OnSpeakerphoneHookSwitch event is fired when the SpeakerphoneHookSwitch state changes. The current state for the etPhone1.Speakerphone HookSwitch properties are displayed in the log and the RadioButtonSPOffHook and RadioButtonSPOffHook controls are updated.

etPhone1_OnSpeakerphoneVolume The etPhone1.OnSpeakerphoneVolume event is fired when the volume for the speakerphone is adjusted. The etPhone1.Speakerphone.Volume property is displayed in the log. The EditSPVolume control is updated with the new value of etPhone1.Speakerphone.Volume.

etPlay1_OnDone

The etPlay1.OnDone event is fired when the wave file has completed playing. The log is updated to indicate that this event has fired.

etPlay1_OnError The etPlay1.OnError event is fired when an error has occurred while using this control. The log is updated to indicate that this event has fired.

etPlay1_OnLoaded

The etPlay1.OnLoaded event is fired when the entire wave file has finished loading into memory. The log is updated to indicate that this event has fired.

etPlay1_OnLoop The etPlay1.OnLoop event is fired when the wave file has completed playing and it is about to begin playing again. The log is updated to indicate that this event has fired.

etPlay1_OnWarning

The etPlay1.OnWarning event fires when a non-fatal error occurs while playing a .WAV file. A message box is popped up to tell the user about it. If the user presses the “Cancel” button, the value of the Continue variable is set to false which causes the file to stop playing.

etRecord1_OnError The etRecord1.OnError event is fired when an error as occurred while using this control. The log is updated to indicate that this event has fired.

etRecord1_OnWarning

The etRecord1.OnWarning event fires when a non-fatal error occurs while recording a .WAV file. A message box is popped up to tell the user about it. If the user presses the “Cancel” button, the value of the Continue variable is set to false which causes the file to stop recording.

Form_Load It fills the combo box with available TAPI line devices and initializes the line device and the combo box to the first device available.

Form_Resize

Resizes controls to fit the current size of the form.

Form_Unload 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. If the etRecord1.Device.Active property is True then a wave file is currently recording and must be stopped by setting etRecord1.Device.Active = False. The line device is closed by setting the etLine1.Device.Active property to False.

OptionSPOffHook_Click

The etPhone1.Speakerphone.MicrophoneAndSpeaker property is set to the value of this radio button.

OptionSPOnHook_Click The etPhone1.Speakerphone.OnHook property is set to the value of this radio button.

TextSPGain_LostFocus

If the value is outside the valid range for the etPhone.Speakerphone.Gain property, the value is reset.

TextSPVolume_LostFocus If the value is outside the valid range for the etPhone.Speakerphone.Volume property the the value is reset.

TimerAutomatedAnsweringDevice_Timer

The timer is disabled so it will not fire again. Monitoring for silence is stopped by setting etLine1.Call.MonitorSilence.Active = False. Since more than 3 seconds has passed since the etLine.OnConnected event has fired and silence was not detected then it is assumed that this calls was answered by an automated answering device. The log is updated to indicated this.

Answering machine detection in this manner can be reliable, but you may have to modify the properties etLine1.Call.MonitorSilence.Duration and TimerAutomatedansweringDevice.Duration.

 

Subroutine

Description

UpdatePhoneDisplay

This is not an event handler routine. It updates the controls to match the state of the TAPI phone device. If there is no phone connected to the line (etLine.Phone.Available = False), the buttons that have to do with a phone are disabled and the bitmaps showing the phone’s state are hidden.

 

Release Notes

April 21, 2003

Published