Guest

Cisco TCL Scripts for IOS Gateways

Cisco Pre-paid Debitcard Multi-Language Programmer's Reference


Table of Contents

Cisco Pre-Paid Debitcard
Multi-Language
Programmer's Reference

Overview of the Multi-Language Feature
Prerequisites
Multi-Language Feature Implementation
Cisco Connection Online
Documentation CD-ROM
Glossary
Call Flow Example

Cisco Pre-Paid Debitcard
Multi-Language
Programmer's Reference


Version: 9/29/00

This document contains information about the Multi-Language feature, including the following sections:

Overview of the Multi-Language Feature

The baseline prepaid debitcard application supports the playing of pre-recorded static and dynamic prompts for English, Spanish, and Chinese (Mandarin). The building of the dynamic prompts for these languages is performed as part of the Cisco Internetwork Operating System (IOS). If an additional language is needed, it has to be delivered as a change to the Cisco IOS and follow the Cisco IOS release process. This can be a very time-consuming and costly process. The Multi-Language feature provides the user with the ability to accommodate languages, other than those originally implemented in the Cisco IOS, by making changes within the debitcard Tool Command Language (TCL) application. Because the modifications are at the script level, the user can implement any defined language. Script changes are relatively easy when the language's dynamic prompt rules are supplied and translated into the script.

Language exceptions are defined as languages outside the originally supported three languages. This document concentrates on the building of dynamic prompts for language exceptions, rather than static prompts, because the script handles static prompts the same way for all languages. When a language is selected, the script prepends a language prefix and passes that prompt to the interactive voice response (IVR) Application Programming Interface (API) playPrompt verb.

Prerequisites

To use the Multi-Language feature you need the following:

  • The Multi-Language feature script debitcard_multi-lang_Cisco.1.1.0.0.tcl or later
  • Complete set of professionally recorded language prompts for each configured language. Languages available with the Multi-Language feature debitcard script are English (en), Spanish (sp), Mandarin (ch), Thai (th), Cantonese (ca), Japanese (ja), and Russian (ru).
  • Cisco IOS Release 12.1(3)xi or later.
  • The Multi-Language feature is based on the debitcard application; therefore, it requires a RADIUS billing server for AAA.

Restrictions and Configuration

  • When you configure the languages, you must configure them sequentially. You cannot skip language numbers. However, the languages themselves can be configured in any order. Refer to the following example:
router# call application voice debit tftp://dirt/script/debitcard_multi-lang_Cisco.1.1.0.0.tcl
router# call application voice debit uid-len 6
router# call application voice debit language 1 en
router# call application voice debit language 2 th
router# call application voice debit language 3 ru
router# call application voice debit language 4 ja
router# call application voice debit language 5 ca
router# call application voice debit language 6 sp
router# call application voice debit language 7 ch
router# call application voice debit set-location en 0 tftp://dirt/au/en/
router# call application voice debit set-location th 0 tftp://dirt/au/th/
router# call application voice debit set-location ru 0 tftp://dirt/au/ru/
router# call application voice debit set-location ja 0 tftp://dirt/au/ja/
router# call application voice debit set-location ca 0 tftp://dirt/au/ca/
router# call application voice debit set-location sp 0 tftp://dirt/au/sp/
router# call application voice debit set-location ch 0 tftp://dirt/au/ch/
  • When setting up the language selection prompts associated with the configured languages, you must put all the actual files in the language 1 configured directory. Refer again to the above example. The files th_lang_sel2.au, ru_lang_sel3.au, ja_lang_sel4, ca_lang_sel5, sp_lang_sel6 and ch_lang_sel7 must all reside in directory tftp://dirt/au/en/. All other language prompts reside in the individual language directories.
  • The maximum amount that the script handles for $amt and creditTime converted to hours and minutes is 999,999.99.

Related Documentation

  • TCL IVR API Version 1.0 Programmer's Guide
    Version 1.0 commands for writing TCL scripts for the Cisco IVR feature on the Cisco AS5300 gateway.
  • TCL IVR API Version 2.0 Programmer's Guide
    Version 2.0 commands for writing TCL scripts for the Cisco IVR feature on the Cisco AS5300 gateway.
  • RADIUS Vendor-Specific Attributes Voice Implementation Guide
    Reference of Cisco RADIUS VSAs for use with VoIP call authorization.

Developer Support

Developers using this programmer's guide may be interested in joining the Cisco Developer Support Program. This new program has been developed to provide you with a consistent level of support that you can depend on while leveraging Cisco interfaces in your development projects.

A signed Developer Support Agreement is required to participate in this program. For more details, and access to this agreement, please visit us at http://www.cisco.com/warp/public/779/servpro/programs/ecosystem/devsup/ or contact developer-support@cisco.com.

Multi-Language Feature Implementation

The Multi-Language feature is built on the application infrastructure of the debitcard script. The script is rewritten, but the call flow from debitcard is essentially unmodified. The original call flow is followed through all procedures for selecting a language, collecting a card number, performing authorization, and placing a call. The modifications necessary for the Multi-Language feature were made to procedures do_get_dest and do_second_authorization to accommodate the playing of pre-recorded dynamic creditAmount and creditTime for the new languages.

How to Use the Multi-Language Feature

This section of the document includes information on how to use the feature:


Step 1   Build the language's master prompt spreadsheet. This will be used to determine the language exceptions and how the language should build dynamic prompts.

Step 2   Determine what numbering structure the language belongs to. Is it SSDHTT, SDDHTT, or another form? Refer to the example in Table 1 to determine if modifications in procedure do_whole_part are required.

Step 3   Based on the numbering structure, modify the necessary procedures. If a language has a dynamic prompt exception for a digit, as defined in Table 1, then add the language prefix to the switch in the necessary procedure (do_tens, do_hundreds, do_thousands, or do_hthousands). See "Modifying the Existing Script". Under most circumstances, the switch default case should not have to be modified.

Table 1   Language Exception Number Translation Form

Digit 1 Digit 2 Digit 3 Digit 4 Digit 5 Digit 6

Cantonese (ca)

S

S

D

H

T

T

Thai (th)

S

D

D

H

T

T

Japanese (ja)

S

S

D

H

T

T

Russian (ru)

S

D

D

H

T

T

Testing and Debugging Your Multi-Language Script

Sample test tools and cases are bundled with the script.

Modifying the Existing Script

Modification of the existing script is based on the specific constructs of the required language. Each modification is different but is made to some or all of the procedures:

  • do_get_dest
  • do_second_authorization
  • do_whole_part
  • do_decimal_part
  • do_creditTime_prompt
  • do_tens
  • do_hundreds
  • do_thousands
  • do_hthousands

The modifications are made by adding a new TCL switch case for the language prefix with the TCL statements that define the language dynamic prompt to the switch statement.

New TCL Procedures

Included in this guide are seven new TCL procedures that can be used to build the language-specific dynamic prompts, while modifications were made in procedures do_get_dest and do_second_authorization. To implement a language exception, the procedures do_get_dest and do_second_authorization, as well as at least some of the other seven procedures, must be modified.

Proc do_get_dest

This modified procedure is used after successful first authorization. A TCL switch statement is included that directs the flow to the language exception procedures or uses the default for Cisco IOS implemented languages. For the TCL implemented language exceptions, this procedure separates the billing server returned amount (creditAmt) into two parts and calls the prompt building procedures of do_whole_part and do_decimal_part.


Note      Some TCL script implementations must be based on the returned values from the RADIUS billing server for creditAmt and creditTime.



Example 1   Sample Modifications to Procedure do_get_dest
switch -regexp $prefix {
{ru} {set newlist [split $amt .]
set gender m
do_whole_part
if {$len == 1} {
switch -regexp $numbers(tens) {
{0} { }
{1} {lappend prompt "[set prefix]_dollar.au"}
{[2-4]} {lappend prompt "[set prefix]_2-4_dollars.au"}
{[5-9]} {lappend prompt "[set prefix]_5-20_dollars.au"}
}
} else {
switch -regexp $numbers(tens) {
{[0-9]*[0|2-9][2-4]} {lappend prompt "[set prefix]_2-4_dollars.au"}
{[0-9]*[2-9][1]} {lappend prompt "[set prefix]_dollar.au"}
default {lappend prompt "[set prefix]_5-20_dollars.au"}
}
}
set gender f
do_decimal_part
if {[string length [lindex $newlist 1]] == 1} {
switch -regexp [lindex $newlist 1] {
{0} { }
default {lappend prompt "[set prefix]_5-20_cents.au"}
}
} else {
switch -regexp [lindex $newlist 1] {
{00} { }
{[0|2-9][1]} {lappend prompt "[set prefix]_cent.au"}
{[0|2-9][2-4]} {lappend prompt "[set prefix]_2-4_cents.au"}
default {lappend prompt "[set prefix]_5-20_cents.au"}
}
}
puts "\t\t**** playPrompt param3 info [set prefix]_you_have.au $prompt [set prefix]_enter_dest.au"
set ev [eval [list playPrompt param3 info [set prefix]_you_have.au] $prompt [list %s1000 [set prefix]_enter_dest.au]]
}
default {set ev [playPrompt param3 info [set prefix]_you_have.au %a$amt %s1000 [set prefix]_enter_dest.au]}
}
Proc do_second_authorization

This is a modified procedure, used after successful authorization to play the dynamic prompt for creditTime. A TCL switch statement is included that directs the flow to the language exception procedures or uses the default for Cisco IOS implemented languages.

Proc do_whole_part

This new procedure separates the whole number string into its numeric prompt components for tens, hundreds, thousands, and hundred thousands. This is explained in more detail in Table 1. This procedure places these values in the numbers array and calls the appropriate procedure based on the arrays index containing a value, as shown in the following example.


Example 2   Example of Procedure do_whole_part
global amt
global prefix
global prompt
global numbers
global len
global newlist
set numbers(tens) ""
set numbers(hundreds) ""
set numbers(thousands) ""
set numbers(hthousands) ""
set len [string length [lindex $newlist 0]]
set separate [split [lindex $newlist 0] ""]
puts "\t\t**** TTS whole part: [lindex $newlist 0]"
# Do the number group translation
switch -regexp $len {
{1} { set numbers(tens) [lindex $separate 0]}
{2} { set numbers(tens) [join [list [lindex $separate 0] [lindex $separate 1]] "" ]}
{3} { set numbers(hundreds) [lindex $separate 0]
set numbers(tens) [join [list [lindex $separate 1] [lindex $separate 2]] "" ]}
{4} { set numbers(thousands) [lindex $separate 0]
set numbers(hundreds) [lindex $separate 1]
set numbers(tens) [join [list [lindex $separate 2] [lindex $separate 3]] "" ]}
{5} {switch -regexp $prefix {
{ca} -
{ja} {set numbers(hthousands) [lindex $separate 0]
set numbers(thousands) [lindex $separate 1]}
default {set numbers(thousands) [join [list [lindex $separate 0] [lindex $separate 1]] "" ]}
}
set numbers(hundreds) [lindex $separate 2]
set numbers(tens) [join [list [lindex $separate 3] [lindex $separate 4]] "" ]
}
{6} {switch -regexp $prefix {
{ca} -
{ja} { set numbers(hthousands) [join [list [lindex $separate 0] [lindex $separate 1]] "" ]
set numbers(thousands) [lindex $separate 2]}
default { set numbers(hthousands) [lindex $separate 0]
set numbers(thousands) [join [list [lindex $separate 1] [lindex $separate 2]] "" ]}
}
set numbers(hundreds) [lindex $separate 3]
set numbers(tens) [join [list [lindex $separate 4] [lindex $separate 5]] "" ]
}
}
foreach index {hthousands thousands hundreds tens} {
if {[string compare $numbers($index) ""] != 0} {
puts "\t\t**** Executing do_$index $numbers($index)"
do_$index
}
Proc do_tens

This new procedure is used to build the language dynamic prompt for the value stored in the numbers (tens) array index. In this procedure, the language exception code is written if the language handles the tens numbers different than the default method.


Example 3   Example of Procedure do_tens
proc do_tens {} {
global prompt
global prefix
global numbers
global len
global gender
if {$numbers(tens) != 0} {
switch -regexp $prefix {
{th} {if {$len == 1} {
lappend prompt "[set prefix]_$numbers(tens).au"
} else {set separate [split $numbers(tens) ""]
switch -regexp $numbers(tens) {
{00} { }
{10} {lappend prompt "[set prefix]_$numbers(tens).au"}
{[0][1-9]} {lappend prompt "[set prefix]_[lindex $separate 1].au"}
{[1][1-9]} {lappend prompt "[set prefix]_10.au" "[set prefix]_[lindex $separate 1].au" }
{[2][0]} {lappend prompt "[set prefix]_20.au"}
{[2][1-9]} {lappend prompt "[set prefix]_20.au" "[set prefix]_[lindex $separate 1].au"}
{[3-9][0]} {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_10.au"}
default {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_10.au" "[set prefix]_[lindex $separate 1].au"}
}
}
}
default {if {$len == 1} {
switch -regexp $numbers(tens) {
{0} { }
default {lappend prompt "[set prefix]_$numbers(tens).au"}
}
} else {set separate [split $numbers(tens) ""]
switch -regexp $numbers(tens) {
{00} { }
{[0][1-9]} {lappend prompt "[set prefix]_[lindex $separate 1].au"}
default {lappend prompt "[set prefix]_$numbers(tens).au"}
}
}
}
}
}
return 0
}

Proc do_hundreds

This new procedure is used to build the language dynamic prompt for the value stored in the numbers (hundreds) array index. In this procedure, the language exception code is written if the language handles the hundreds numbers different than the default method, as shown in the following example.


Example 4   Example of Procedure do_hundreds
proc do_hundreds {} {
global prompt
global prefix
global numbers
if {$numbers(hundreds) == 0} {
switch -regexp $prefix {
{ca} { if {$numbers(tens) >= 10 } {
lappend prompt "[set prefix]_0.au"
} else {
return 0
}
}
default {return 0}
}
} else {
switch -regexp $prefix {
{ru} {lappend prompt "[set prefix]_$numbers(hundreds)00.au"}
{ja} {switch -regexp $numbers(hundreds) {
1 {lappend prompt "[set prefix]_hyaku.au"}
3 {lappend prompt "[set prefix]_san_byaku.au"}
6 {lappend prompt "[set prefix]_ro_pyaku.au"}
8 {lappend prompt "[set prefix]_happyaku.au"}
default {lappend prompt "[set prefix]_$numbers(hundreds).au" "[set prefix]_hyaku.au"}
}
}
default {lappend prompt "[set prefix]_$numbers(hundreds).au" "[set prefix]_hundred.au"}
}
}
return 0
}

Proc do_thousands

This new procedure is used to build the language dynamic prompt for the value stored in the numbers (thousands) array index. In this procedure, the language exception code is written if that language handles the thousands numbers different than the default method. The language form explained in Table 1 has an effect on how the language is implemented in this procedure. The procedure has to know if the numbers (thousands) array index contains a one- or two-digit number.


Example 5   Example of Procedure do_thousands
proc do_thousands {} {
global prompt
global prefix
global numbers
global len
if {$numbers(thousands) == 0} {
switch -regexp $prefix {
{ca} {if {($numbers(hundreds) == 0) && ($numbers(tens) >= 10) } {
lappend prompt "[set prefix]_0.au"
}
}
{th} -
{ja} { }
default {lappend prompt "[set prefix]_thousand.au"}
}
} else {
switch -regexp $prefix {
{th} {if {$len == 4} {
lappend prompt "[set prefix]_$numbers(thousands).au" "[set prefix]_thousand.au"
} else {
set separate [split $numbers(thousands) ""]
switch -regexp $numbers(thousands) {
{00} { }
{[0][1-9]} {lappend prompt "[set prefix]_[lindex $separate 1].au" "[set prefix]_thousand.au"}
{[1-9][0]} {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_ten_thousand.au"}
default {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_ten_thousand.au" "[set prefix]_[lindex $separate 1].au" "[set prefix]_thousand.au"}
}
}
}
{ja} {switch -regexp $numbers(thousands) {
1 {lappend prompt "[set prefix]_thousand.au"}
3 {lappend prompt "[set prefix]_san_zen.au"}
8 {lappend prompt "[set prefix]_ha_ssen.au"}
default {lappend prompt "[set prefix]_$numbers(thousands).au" "[set prefix]_thousand.au"}
}
}
default {lappend prompt "[set prefix]_$numbers(thousands).au" "[set prefix]_thousand.au"}
}
}
return 0
}

Proc do_hthousands

This new procedure is used to build the language dynamic prompt for the value stored in the numbers (hthousands) array index. In this procedure, the language exception code is written if that language handles the hundred thousand numbers different than the default method. The language form explained in Table 1 has an effect on how the language is implemented in this procedure. The procedure has to know if the numbers (hthousands) array index contains a one- or two-digit number.


Example 6   Example of Procedure do_hthousands
proc do_hthousands {} {
global prompt
global prefix
global numbers
set hlen [string length $numbers(hthousands)]
switch -regexp $prefix {
{th} {lappend prompt "[set prefix]_$numbers(hthousands).au" "[set prefix]_hundred_thousand.au"}
{ca} {if {$hlen == 1} {
lappend prompt "[set prefix]_$numbers(hthousands).au" "[set prefix]_ten_thousand.au"
} else {set separate [split $numbers(hthousands) ""]
switch -regexp $numbers(hthousands) {
{[1][1-9]} {lappend prompt "[set prefix]_10.au" "[set prefix]_[lindex $separate 1].au" "[set prefix]_ten_thousand.au"}
{[2-9][0]} {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_10.au" "[set prefix]_ten_thousand.au"}
default {lappend prompt "[set prefix]_[lindex $separate 0].au" "[set prefix]_10.au" "[set prefix]_[lindex $separate 1].au" "[set prefix]_ten_thousand.au"}
}
}
}
{ja} {switch $numbers(hthousands) {
1 {lappend prompt "[set prefix]_ichi_man.au"}
default {lappend prompt "[set prefix]_$numbers(hthousands).au" "[set prefix]_man.au"}
}
}
{ru} {lappend prompt "[set prefix]_$numbers(hthousands)00.au"}
default {lappend prompt "[set prefix]_$numbers(hthousands).au" "[set prefix]_hundred.au"}
}
return 0
}

Proc do_decimal_part

This new procedure separates the decimal number string into its numeric prompt components following the languages rules for tens. This is explained in more detail later in this section.


Example 7   Example of Procedure do_decimal_part
proc do_decimal_part {} {
global newlist
global prompt
global prefix
global gender
# Do the decimal translation
puts "\t\t*** TTS decimal part: [lindex $newlist 1]"
switch -regexp $prefix {
{th} {if {[string length [lindex $newlist 1]] == 1} {
switch -regexp [lindex $newlist 1] {
{0} { }
default {lappend prompt "[set prefix]_[lindex $newlist 1]0.au"}
}