Walkthrough: Use Global Variable with Entry.bas Script to Play Rotating Advertisement

In this walkthrough we will use a Global Variable defined in an Entry.bas script to set the starting Advertisement Number.  The Advertisement Number will be incremented sequentially to determine the current Advertisement Number to use.  Each Advertisement will be set-up as an Announcement Type Mailbox whose Mailbox # will be equal to the Advertisement Number and the Mailbox Greeting will be the Advertisement message.  Each Advertisement message will be played sequentially at the start of a call across all lines.

Walkthrough Overview

In this walkthrough, you will:

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

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

Prerequisites and Assumptions

Create Mailbox Records

For this walkthrough we will use 9900 as the first Advertisement Number and 9905 as the last Advertisement Number.  We will reserve mailbox numbers 9900 thru 9999 for Advertisement.  There must be a sequentially numbered mailbox records set-up and used.  

For each record, the Mailbox # will be equal to the Advertisement Number, the Type set to Announcement, and Allow Login During Greeting enabled.  Each mailbox will have Settings UL3 (limit owner options to 3) and NGN (do not require mailbox name and greeting for first time login).  Add any other optional information as desired. 

Note: Keep Mailbox record 0000 with the default settings as CALLMaster requires it.  You should change the password for this record to maintain security.

Open the CALLMaster Manager. Click on Manage, then select Mailboxes.  Let's add the records in this walkthrough as follows:

Mailbox Records
Mailbox Password Last Name Settings Type
9900 9900 Advertisement 9900 UL3 NGN Announcement
9901 9901 Advertisement 9901 UL3 NGN Announcement
9902 9902 Advertisement 9902 UL3 NGN Announcement
9903 9903 Advertisement 9903 UL3 NGN Announcement
9904 9904 Advertisement 9904 UL3 NGN Announcement
9905 9905 Advertisement 9905 UL3 NGN Announcement

As the mailbox has Setting UL3, only the first 3 Set Personal Option Features will be available.  The changes made will take effect as soon as the owner logs out.

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 hear aa Advertisement message.  There will be a sequential rotation thru the list of Advertisement, with each Advertiser having the ability to record their message at any time.

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)
10 Start call and Initialize values Yes Next Module 100 9900 0 InitializeVal.bas
100 Send caller to associated Advertisement Mailbox Yes Mailbox 9999 9900 0 GetAdvertisementNo.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
9999 Last Module - End call Yes Last Module        

Audiotex Module Description

Based on the Audiotex modules shown above, we will need 4 scripts as well as the Entry.bas script. 

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 - Entry.bas Copy to Clipboard
Program
'**************************************************************************************************************************
'     Script:  Entry.bas
'     Function:  Runs at CALLMaster Service start-up.  Used to initialize global variables.
'**************************************************************************************************************************

     Print "CM Entry Script started on "
     PrintNL $today

     ' @intAdvertisementNo set to the first Advertisement Number
     @intAdvertisementNo = 9900

EndProgram

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

     ' Set retry counter and maximum attempts allowed counter
     intTryCount = 1
     intMaxAttemptsAllowed = 3

     ' Assign the starting and ending Advertisement numbers
     intFirstAdvertisementNo = 9900
     intLastAdvertisementNo = 9905
     intCurrAdvertisementNo = 0

     ' 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 - GetAdvertisementNo.bas Copy to Clipboard
Program
'*************************************************************************************************************************************
'     Script:  GetAdvertisementNo.bas
'     Function:  This script checks the value of global variable @intAdvertisementNo to create the current Advertisement ID.
'*************************************************************************************************************************************


     ' If the global variable @intAdvertisementNo is greater than the last Advertisement Number (intLastAdvertisementNo), reset the global variable @intAdvertisementNo to the first Advertisement No (intFirstAdvertisementNo); if not then it is incremented by 1.
     If @intAdvertisementNo = intLastAdvertisementNo Then
        @intAdvertisementNo = intFirstAdvertisementNo
     Else
        @intAdvertisementNo = @intAdvertisementNo + 1
     EndIf

     ' The local variable intCurrAdvertisementMBNo is set as the current Advertisement Number.
     intCurrAdvertisementMBNo = @intAdvertisementNo

     ' Convert local variable intCurrAdvertisementMBNo from integer to string to be used in concatenated print statement.
     IntegerToString strCurrAdvertisementMBNo intCurrAdvertisementMBNo
     pline = "***** For channel=" & strchannel
     pline = pline & " Caller sent to current Advertisement mailbox "
     pline = pline & strCurrAdvertisementMBNo
     PrintNL pline

     ' The Return command is used to send caller to the Advertisement's mailbox.
     Return intCurrAdvertisementMBNo

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 = "***** 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 = "***** Caller Hangup. *****"
     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 10.  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
10 Rotating Message 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 10.

As this walkthrough uses Notification, make sure at least one port is enabled for Type Outbound; all the ports should be enabled for Inbound. 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 Type
Outbound
Port Greeting File IDs
(Morning, Afternoon, Evening, Closed, Holidays)
1 Rotating Message Walkthrough 10 No 0, 0, 0, 0, 0
2 Rotating Message Walkthrough 10 No 0, 0, 0, 0, 0
3 Rotating Message Walkthrough 10 Yes 0, 0, 0, 0, 0
4 Rotating Message Walkthrough 10 Yes 0, 0, 0, 0, 0

Test the custom application

Save all your work. 

Stop CALLMaster service.

Make Mailbox Recordings:

-  Set Port 1 to Application Voice Mail.

-  Start CALLMaster service.

-  Make a call using Port 1.

Log in to each Advertisement Mailbox using the Voice Mail Main Menu and record mailbox name, greeting and directory listing.

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 for ongoing recording changes.