The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ivrs - Perl extension for Interactive Voice Response System.

SYNOPSIS

$iv = new Ivrs($portname,$vdir);

DESCRIPTION

This module provides the complete interface to voice modem for Interactive Voice Response System (IVRS). The IVRS are widely used for telebanking, product inforamtion, tele marketing, voice mail, fax servers, and many more. All these can be implemented using this module and with very few lines of Perl code. This module takes care of all low level functions of serial port and modem.

A log file defined by the $logfile="/var/log/Ivrs_Log.ttyS*" will be opened for logging IVRS activity. Set $Babble =0 if you do not want to log all the messages (default is 1).

EXAMPLE

The demo files explains the working of various subroutines of the module.

demo1 - A simple voice interaction.

demo2 - Message recording and playback.

demo3 - Fax server.

demo4 - Dial a telephone number.

demo5 - Transfer caller line to another phone

METHODS

$iv = new Ivrs('ttyS1',$vdir);

The first variable is the port name for modem / serial port (ttyS0 or ttyS1)

The second variable $vdir is voice file directory. You must specify $vdir if you want to use other than default directory ( sfiles/ ). If you are running IVRS from /etc/inittab (YES!! you can do) then absolute path for voice files is must.

Initilization.

$iv->setport('38400','none','8','1','rts','8096');

The serial port parameters are set here. These parameters are carefully worked out after extensive trials. Change only if you know what are you doing or if these settings do not work on your modem.

$iv->initmodem;

This will put the modem in voice mode. Number of AT commands are required to set this. You may comment out the AT commands which do not start with AT# if your modem fails to respond. Some modem uses AT+ for voice commands. In that case you will have to replace all AT# with AT+.

$cid=$iv->waitring;

This will put the modem in answer mode and wait for the ring. When the ring comes, call will be received on the first ring and Caller ID will be returned in $cid (not tested so far).

If you want to play a message directly (without some one calling) through Modem speaker then skip it and put $iv->atcomm("AT#VTX","CONNECT"); but then you will not be able to punch DTMF codes.

Play messages.

$iv->playfile("$msgfile","$dtmf")

This requires a bit of explanation. From version 0.06, the use of lin file is removed and all files are raw modem data (Rockwell Modem, 7200 samples per second with compression Type 4) type only, So pvftools are no longer required to run the IVRS.

The $msgfile contains the message file to be played. You can specify the full path of the file like, /home/Ivrs-0.07/sfiles/greet or only file name (like greet) from voice file directory. If no file name is specified, it will play special file indicated by $tmpmsg. I will discuss this file in next section.

Another variable required is $dtmf, which is number of dtmf codes to be accpeted from the user while playing the file.

If $dtmf=0 then playing of file will not be stopped even if caller presses any key.

If $dtmf=1, then playing of file will be immidiately stopped if the caller presses first dtmf code and $iv->playfile will return the digit pressed.

If $dtmf=2 or more, then playing of specified file will be stopped when caller presses first digit and next a silence (tsil15) of 15 seconds will played, for caller to enter remaining digits. When caller has pressed required number of digits ($dtmf) then playing will be stopped and $iv->playfile will return with complete dtmf digits.

if $dtmf = * OR # then playing will stop and DTMF code punched by caller prior to * OR # will be returned.

$iv->addmsg($msg)

$iv->addval($val)

$iv->addmil($val)

$iv->addtxt("ABCDEF")

$iv->addate("20001212")

IVRS requires many messages to be generated on the fly and then played to caller, like numbers in numerical format, date etc. The default voice directory sfiles/ has number of rmd files. These files can be cut and pasted as required. The above mentioned routines adds up various rmd files to a file specified by $tmpmsg, and finally this file is played to caller. For example to play number 123 to caller, files (from sfiles/) '1','hundred', '20' and '3' will be added to $tmpmsg, and then played.

$iv->addmsg($msg)

Add a message from sfiles/

$iv->addval($val)

Add a numeric value in Indian format (using lacs and crore)

$iv->addmil($val)

Same as above but with International format (using milions and billions)

$iv->addtxt("ABCDEF")

Add characters (A-Z and 0-9)

$iv->addate("20001212")

Add date in yyyymmdd format.

Record Messages.

$iv->recfile($filename,$duration)

This will record the file $filename in rmd format with proper header for a period of $duration seconds. This rmd file can be converted to any format using pvftools like rmdtopvf and pvftowav.

Other Functions.

$iv->dialout($telno)

You can dial out a number, however code is experimental, it worked with US Robotics modem only.

$iv->callxfer($telno)

You can transfer a call, however code is experimental, it worked with US Robotics modem only.

$iv->faxmode

This will put the modem in fax mode and you can run efix and efax to send the fax. This should be last instruction in your script. Also install efax or copy these files from bin/ directory to your /usr/bin.

Close.

$iv->closep

This will do some cleanup, hangup the line and reset the modem.

THANKS

I thank Bill Birthisel, wcbirthisel@alum.mit.edu, for serial port code taken from SerialPort.pm,

COPYRIGHT

Copyright (c) 2002 Mukund Deshmukh. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Mukund Deshmukh <betacomp@nagpur.dot.net.in>

SEE ALSO

SerialPort.pm, pvftools