In the present scenario, the public fully depends on leading and well-established financial institutions like banks, foreign exchanges etc. to get the latest currency rates. These institutions should have sufficient staff to handle such customers. It is not feasible to have staff only for managing the information centre. So, Xtend IVR introduces an automated approach to deal with currency rates and conversions.
Download the evaluation version of Xtend IVR and install the telephony application in your system. Run the sample script from the Script Editor. Click here to refer the sample code. For an alternative approach, click here.
The automated attendant will work as given below:
MAIN:
display "Waiting for call......"
answer 1
display "Call active: " $cli
play "Welcome.wav"
display "Loading currency rates"
load "CurrencyRates.txt"
display "accept the amount to be converted"
$amount = accept("amount.wav",8,2,2)
if $amount = 0 then goto BYE
MENU:
play "source.wav"
$source = accept("currencymenu.wav",1)
if $source = 0 then goto BYE
if $source > 6 then goto MENU
CONVERT:
play "target.wav"
$target = accept("currencymenu.wav",1)
if $target = 0 then goto BYE
if $target > 6 then goto MENU
OUTPUT:
if $source = 1
$sr = $Currency1.Rate
$srn = $Currency1.Des
else if $source = 2
$sr = $Currency2.Rate
$srn = $Currency2.Des
else if $source = 3
$sr = $Currency3.Rate
$srn = $Currency3.Des
else if $source = 4
$sr = $Currency4.Rate
$srn = $Currency4.Des
else if $source = 5
$sr = $Currency5.Rate
$srn = $Currency5.Des
else if $source = 6
$sr = $Currency6.Rate
$srn = $Currency6.Des
endif
if $target = 1
$tr = $Currency1.Rate
$trn = $Currency1.Des
$wav = $Currency1.Wave
else if $target = 2
$tr = $Currency2.Rate
$trn = $Currency2.Des
$wav = $Currency2.Wave
else if $target = 3
$tr = $Currency3.Rate
$trn = $Currency3.Des
$wav = $Currency3.Wave
else if $target = 4
$tr = $Currency4.Rate
$trn = $Currency4.Des
$wav = $Currency4.Wave
else if $target = 5
$tr = $Currency5.Rate
$trn = $Currency5.Des
$wav = $Currency5.Wave
else if $target = 6
$tr = $Currency6.Rate
$trn = $Currency6.Des
$wav = $Currency6.Wave
endif
$result = format("%.3f",($amount * $sr) / $tr)
play num2wav($result,"","",1)
play $wav
display format("%.3f %s -> %.3f %s",$amount,$srn,$result,$trn)
BYE:
play "thanku.wav"
hangup
goto MAIN
ONHANGUP:
hangup
goto MAIN
ONSYSTEMERROR:
log $error
display $error
hangup
goto MAIN
MAIN:
display "Waiting for call......"
answer 1
display "Call active: " $cli
play "Welcome.wav"
display "Loading currency rates"
$index = 0
load "CurrencyRates.txt"
display "accept the amount to be converted"
$amount = accept("amount.wav",8,2,2)
if $amount = 0 then goto BYE
MENU:
$source = GetType("source.wav")
if $source = 0 then goto BYE
if $source > $index then goto MENU
CONVERT:
$target = GetType("target.wav")
if $target = 0 then goto BYE
if $target > $index then goto MENU
OUTPUT:
$srn = format("$Currency%d.Des",$source)
$trn = format("$Currency%d.Des",$target)
$sr = format("$Currency%d.Rate",$source)
$tr = format("$Currency%d.Rate",$target)
$result = format("%.3f",($amount * $$sr) / $$tr)
$result += 0
$wav = format("$Currency%d.Wave",$target)
play num2wav($result,"","",1)
play $$wav
display format("%.3f %s -> %.3f %s",$amount,$$srn,$result,$$trn)
BYE:
play "thanku.wav"
hangup
goto MAIN
ONHANGUP:
hangup
goto MAIN
ONSYSTEMERROR:
log $error
display $error
hangup
goto MAIN
function GetType($prompt)
play $prompt
$i = 1
while true
$var = format("$Currency%d.Wave",$i)
if IsVariable($var) = 0
$i -= 1
break
endif
play "for.wav"
play $$var
play "dial.wav"
play num2wav($i)
$i += 1
endwhile
SetVariable("$index",$i)
$val = input(1,4)
return $val