Walkthrough: Get Variable Length Input Using GetDTMF and Play Back Input Entered

In this walkthrough we will get a variable length input from the caller and play back input entered.

Walkthrough Overview

In this walkthrough, you will:

  1. Create Audiotex Records/Modules and Associated Scripts;
  2. Define entry in the IVR Application List for the new custom IVR;
  3. Set Ports.

During this walkthrough, you will learn to do the following:

Prerequisites and Assumptions

Create Audiotex Records/Modules and Associated Scripts

As all calls will be starting in Audiotex mode in this walkthrough, the Audiotex Modules will determine the call flow.

In the Audiotex set-up, the caller will be asked to input a variable length number, which will be played back to them.

We will need to create several Audiotex records as shown below.  The Label field provides a brief description of each module.  

Audiotex Records
Module ID Label Write Label
to Log File
Module
Action
Next Module ID Fail Module ID Response
Length
Script File to Run
(Must include full path name)
1000 Start call and Initialize values Yes Next Module 1100 9900 0000 InitializeVal.bas
1100 Get variable length input from caller Yes Next Module 1200 9900 0 GetDTMF-VarLen.bas
1190 Invalid input.  Yes Next Module 1191 9900 0 CheckTryCount.bas
1191 Try again. Yes Next Module 1100 9900 0  
1200 Say input entered Yes Next Module 9999 9900 0 SayNumberInput.bas
9900 Call Failure Detected Yes Next Module 9999 9999 0 SetCallFailure.bas
9910 Caller Hang-up Detected Yes Next Module 9999 9999 0 SetCallerHangup.bas
9920 Maximum tries attempted Yes Next Module 9999 9999 0 SetMaxAttempts.bas
9999 Last Module - End call Yes Last Module        

Audiotex Module Description

Based on the Audiotex modules shown above, we will need several scripts. 

Let's create the scripts first.  Open Notepad and create scripts following code examples below.  Remember to save them as .bas type files in the Program Files\CALLMaster\Scripts folder.

CALLBasic Script - InitializeVal.bas Copy to Clipboard
Program
'***************************************************************************************************************
'     Script:  InitializeVal.bas
'     Function:  This script is used to initialize values
'***************************************************************************************************************

     strYes = "Yes"
     strNo = "No"
     intYes = 1
     intNo = 0
     strCallFailure = strNo
     strCallerHangup = strNo
     strMaxAttempts = strNo
     intOne = 1

     ' Set retry counter and maximum attempts allowed
     intTryCount = 1
     intMaxAttemptsAllowed = 3
 
     ' Set intMaxInputLen to include maximum number allowed plus the termination digit
     intMaxInputLen = 6
     strTermDigit = "*"

     ' Set the module to return to if caller hangs up
     lctrap = 9910

     ' Convert system variable $channel from integer to string to be used in concatenated print statement.
     IntegerToString strchannel $channel

     pline = "***** For channel=" & strchannel
     pline = pline & " Started initialization process "
     PrintNL pline


EndProgram

CALLBasic Script - GetDTMF-VarLen.bas Copy to Clipboard
Program
'***************************************************************************************************************
'     Script:  GetDTMF-VarLen.bas
'     Function:  This script gets a variable length input from the caller. 
'***************************************************************************************************************

     '  Set up parameters for GetDTMF command
     strNoInput = ""
     strNoInput-wo-termdigit = ""
     tmask = strTermDigit
     ndigits = intMaxInputLen
     timeout = 15

     GetDTMF strNoInput tmask ndigits timeout

     ' Get length of input
     StringLength intlen strNoInput

     pline = "***** For channel=" & strchannel
     pline = pline & " strNoInput entered is "
     pline = pline & strNoInput
     PrintNL pline

     ' Check caller input.  The caller must enter more than 1 digit
     ' Save selected option

     If intlen < 2 Then
        pline = "***** For channel=" & strchannel
        pline = pline & " Invalid strNoInput entered. Return to 1190 for error and retry"
        PrintNL pline
        Return 1190
     Else
        intTryCount = 0
     EndIf

     ' Strip off termination mask digit from input length
     intlenminusone = intlen - 1

     ' Initialize count start position
     intstart = 0

     ' Move/Copy digits input to new variable
     MemMove strNoInput-wo-termdigit strNoInput intstart intlenminusone

EndProgram

CALLBasic Script - CheckTryCount.bas Copy to Clipboard
Program
'********************************************************************************************************************
'     Script:  CheckTryCount.bas
'     Function:  This script checks the number of invalid input attempts. 
'********************************************************************************************************************

     '  If the caller has reached the maximum attempts allowed then the call is routed to module 9920. 
     '  If not then they are returned back to module 1000 to retry input based on Next Module ID.
     If intTryCount > intMaxAttemptsAllowed Then
        Return 9920
     Else
        intTryCount = intTryCount + 1
     EndIf

     ' Convert system variable intTryCount from integer to string to be used in concatenated print statement.
     IntegerToString strTryCount  intTryCount

     pline = "***** For channel=" & strchannel
     pline = pline & " TryCount = "
     pline = pline & strTryCount
     PrintNL pline

EndProgram

CALLBasic Script - SayNumberInput.bas Copy to Clipboard
Program
'*********************************************************************************************************************
'     Script:  SayNumberInput.bas
'     Function:  This script says the Number Input.
'*********************************************************************************************************************

     SayNumeral strNoInput-wo-termdigit

     'Print information to log file for reference and debugging
     pline = "***** For channel=" & strchannel
     pline = pline & "***** Number played back to caller is *****"
     pline = pline & strNoInput-wo-termdigit
     PrintNL pline

EndProgram

CALLBasic Script - SetCallFailure.bas Copy to Clipboard
Program
'*******************************************************************************************************************
'     Script:  SetCallFailure.bas
'     Function:  This script sets the strCallFailure variable to yes and prints information in the call log file.
'*******************************************************************************************************************

     strCallFailure = strYes

     'Print information to log file for reference and debugging
     pline = "***** For channel=" & strchannel
     pline = pline & "***** Call Failure. *****"
     PrintNL pline

EndProgram

CALLBasic Script - SetCallerHangup.bas Copy to Clipboard
Program
'*********************************************************************************************************************
'     Script:  SetCallerHangup.bas
'     Function:  This script sets the strCallFailure variable to yes and prints information in the call log file. 
'*********************************************************************************************************************

     strCallerHangup = strYes

     'Print information to log file for reference and debugging
     pline = "***** For channel=" & strchannel
     pline = pline & "***** Caller Hangup. *****"
     PrintNL pline

EndProgram

CALLBasic Script - SetMaxAttempts.bas Copy to Clipboard
Program
'*********************************************************************************************************************
'     Script:  SetMaxAttempts.bas
'     Function:  This script sets the strMaxAttempts variable to yes and prints information in the call log file. 
'*********************************************************************************************************************

     strMaxAttempts  = strYes

     'Print information to log file for reference and debugging
     pline = "***** For channel=" & strchannel
     pline = pline & "***** Maximum Attempts reached to enter valid input *****"
     PrintNL pline

EndProgram

Now you can create the Audiotex modules and reference the scripts above.  Open the CALLMaster Manager, click on Manage, then select Audiotex to add the Audiotex records shown above.

Define IVR Application List Entry

We need to define the custom IVR in the IVR Application List and set it to Audiotex Start Module 1000.  Open CALLMaster Manager and select Manage | IVR Application List.  Let's add a new record as follows:

IVR Application List
Audiotex Start Module Application Name
1000 Variable Length Input Walkthrough

Set Ports

As a last step, we need set the port(s) to the new IVR Application entry created above.  Make sure the Audiotex Start Module field (read only) correctly points to module 1000.

 Set the Port Greeting File IDs to the main greeting for all calls if you have recorded one.  If you do not want a main greeting then set the Greeting File IDs to zero. Leave all other fields to the default values.

If you are working with a demo license or have only one line connected, then make sure the connected port is set as specified below.  All other ports should be set to Application 'Disabled'.

Port Records
Port # Application Audiotex Start Module Port Greeting File IDs
(Morning, Afternoon, Evening, Closed, Holidays)
1 Variable Length Input Walkthrough 1000 0, 0, 0, 0, 0
2 Variable Length Input Walkthrough 1000 0, 0, 0, 0, 0
3 Variable Length Input Walkthrough 1000 0, 0, 0, 0, 0
4 Variable Length Input Walkthrough 1000 0, 0, 0, 0, 0

Test the custom application

Save all your work. 

Stop CALLMaster service.

Make Administrator Audiotex Recordings:

-  Set Port 1 to Application Voice Mail.

-  Start CALLMaster service.

-  Make a call using Port 1.

Log in as the Administrator using the Voice Mail Main Menu and make recordings for the Audiotex modules below.

Audiotex Module ID Proposed Recording
1100 Please enter you ID number followed by the * key.  Remember, your ID cannot be greater than 5 digits.
1190 Invalid option. 
1191 Please try again
1200 You entered ...
9900 We are unable to process your call.  Please contact the system administrator for further assistance.
9920 You have reached the maximum attempts allowed for a valid input.  Please contact the system administrator for further assistance.

Reset Port 1 to Application Audiotex.  Set the Port Greeting File IDs to zeros.

Stop and Start CALLMaster service.

Make a phone call to test the application.

Tip: See Walkthrough: Change Application Without Restarting CALLMaster Service to set port to Voice Mail to make recording without stopping and restarting the CALLMaster service.