VoiceGuide IVR Software Main Page
Jump to content

Pass Information From One Call To Another

Recommended Posts

Nira wrote:

 

I'm trying to count the calls' number (to define a variable -n - that its

value shows how much calls have been done until the current call), because I

want each caller to hear a different message according to the call's number.

 

Here is the vb code I wrote:

 

Dim cond, strResultVariables

n=n+1
If n/4= int(n/4) then
 cond = "music"
ElseIf n/3= int(n/3) then
 cond = "apology_cond"
ElseIf n/2= int(n/2) then
 cond = "no_4" 
Else
 cond = "active"
End If

strResultVariables = "[condition]{" & cond & "}"
iRet = WriteResultFile(strResultVariables)


Function WriteResultFile(strResult)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim filename, fso, ts, outdata, outdata2, outdata3

filename = "VGRUNRESULT_$RV_DEVICEID.TXT" 
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(filename, ForWriting, True)
ts.WriteLine (strResult)
ts.Close
WriteResultFile = 0
End Function

The problem is that n becomes equal to zero with every call. How can I make

n "remember" its value, so in the next call its value will grow by 1?

Share this post


Link to post

To be able to pass the value of 'n' from one call to another you must save it somewhere, and then each call will read the current value of 'n' from that place, then update the value of 'n', and then the next call can read it etc etc...

 

you can save information in :

 

- Text file (can use VB Script module to read/write text file)

- Database (can use DB Query module to read/write Database file)

- Excel Spreadsheet (can use VB Script module to read/write Excel file)

 

But in your case where you want to mix up the message played to caller it's probably best to determine which message should be played based on the value of the $RV_SECOND Result Variable...

Share this post


Link to post

Thanks!

 

As you can see in the code below, I'm saving n's value in a text file.

Now the problem is that while the code runs on a regular visual basic (version 6), it ISN'T runs as a part of interactive voice guide script. I mean, an error message eppears when the code reaches the vbs module.

Any idea why? Thanks in advance!

 

 

 

Dim cond, n, strResultVariables

 

open "D:\nira\n.txt" for input as 1

input #1, n

close 1

 

If n/4= int(n/4) then

cond = "music"

ElseIf n/3= int(n/3) then

cond = "apology_cond"

ElseIf n/2= int(n/2) then

cond = "no_4"

Else

cond = "active"

End If

 

n=n+1

 

open "D:\nira\n.txt" for output as 1

write #1, n

close 1

 

strResultVariables = "[condition]{" & cond & "}"

iRet = WriteResultFile(strResultVariables)

 

 

Function WriteResultFile(strResult)

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim filename, fso, ts, outdata, outdata2, outdata3

 

filename = "VGRUNRESULT_$RV_DEVICEID.TXT"

Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso.OpenTextFile(filename, ForWriting, True)

ts.WriteLine (strResult)

ts.Close

WriteResultFile = 0

End Function

Share this post


Link to post

one thing I found is that you can add msgbox's in your code, and they will popup on the server. a very useful way to debug.

stick plenty of msgbox's in your code to display variables and you'll soon find the problem.

 

it probably is asking a bit much of the voiceguide support people to get them to debug your own code.

 

Tim

Share this post


Link to post

Another thing to keep in mind is that VBScript is a cut down version of Visual Basic - so not all Visual Basic functions will work in VB Script.

Also when an error pos up in VB Script quite often it has the line number and the character number in it, so you can tell exactly where the error occurs..

Share this post


Link to post

Just looking at the script quickly, I'd recommend using a different method of reading the text file.

 

There is an example in VoiceGuide's Help file - section on VB Script module:

set fileVmBoxList = fso.OpenTextFile("D:\nira\n.txt")

sEntireFile = fileVmBoxList.ReadAll

set fileVmBoxList = Nothing

 

sEntireFile will then contain the information read from the file...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×