Jump to content

< Back to Forum


Script Modules

  • Please log in to reply

#1 ThaoHuynh 11 July 2017 - 07:31 PM

Hi VG Team,


I would like to use response result from web service.


ie:   If result = 'a' 

             run module 'Say Card Number'


             run module 'Enter Card Number'

How can i do that?


Thank you for your support.

#2 SupportTeam 11 July 2017 - 08:07 PM

Use an Evaluate Expression module.


The Web Service module will create a number of Result Variables ($RVs). Best to look at vgEngine trace to see what these are. 

If you know the exact XML or JSON that the Web Service returns then you can deduce what $RVs are created, but best/easiest to just look in vgEngine trace after running a call to the Web Service.


Use the Evaluate Expression module to evaluate the $RV that you want to check the value of, and then set paths that match each value.


Say your Web Service module creates this $RV (amongst many others) :




and the above $RV can have values aaaa or bbbb or something else.


then you would use this as expression to evaluate in the Evaluate Expression module (notice the quotes):




and the paths would be:


on {aaaa} goto [Say Card Number]

on {bbbb} goto [SomeModuleB]

on {True} goto [Enter Card Number]

#3 ThaoHuynh 11 July 2017 - 09:01 PM

Thank you so much.


I also have a issue in script module. Can VoiceGuide speak 3 random digits?

#4 SupportTeam 11 July 2017 - 09:41 PM

Use an 'Evaluate Expression' type module to evaluate this expression:


100 + Int(900*Rnd)


this will result in random number between 100 and 999.


The random number will be saved in $RV with the same name as the title of the Evaluate Expression module.


The $RV can then be used in a 'Say Numbers' type module to speak out the digits.


Use a Success or True path to go from the 'Evaluate Expression' type module to the 'Say Numbers' type module.



see vgEngine trace excerpt of a script doing this:


'Evaluate Expression' module was titled: GenerateSomeRnd


It created $RV[GenerateSomeRnd] that held the random number value, and the $RV[GenerateSomeRnd] was then played out by the Say Numbers module:

213304.349  11   5   1 state [GenerateSomeRnd] Evaluate [100 + Int(900*Rnd)]
213304.349  11   5   1       eval  [100 + Int(900*Rnd)]
213304.349  11   5   1       eval  InvokeMember Eval returned
213304.349  11   5   1       rvns  add   GenerateSomeRnd_Input|100 + Int(900*Rnd)
213304.349  11   5   1       rvns  add   GenerateSomeRnd|621
213304.349  11   5   1       Eval Expr result:[621]
213304.349  11   5   1       path {621} not found
213304.349  11   5   1       matching path not found [621], try boolean paths.
213304.349  11   5   1       ex: ScriptIo.VGMTYPE_EVALEXPR [621] could not be converted to boolean. Take Success path as string non-empty.
213304.349  11   5   1       FindNextVgmTitleInPathList: next module title is=[SayRnd]
213304.349  11   5   1       matching path found (Boolean True)
213304.349  11   5   1 t     timer clear (force=False)
213304.349  11   5   1       RunModule start
213304.349  11   5   1       RunModule start Say Numbers, [SayRnd], iModuleIdx=62, previous: vgm=61, vgs=2:2
213304.349  11   5   1       rv    replace start [$RV[GenerateSomeRnd]]
213304.349  11   5   1       rv    replace end   [621]
213304.349  11   5   1 state [SayRnd] Say Numbers: 621 as Digits

#5 SupportTeam 11 July 2017 - 09:49 PM

Also see attached screenshot :

  • script_rrnd.gif
  • script_rrnd_2.gif

#6 ThaoHuynh 12 July 2017 - 12:13 PM

Thank you so so so much.

#7 ThaoHuynh 12 July 2017 - 12:24 PM

Can VoiceGuide get call start time (ie:1/1/2018 09:55:55) and number phone that call has come from?

Can VoiceGuide return times 

#8 SupportTeam 12 July 2017 - 12:41 PM

From Online Help File: "Script Design" -> "Result Variables" section:


The Date and Time the call was started. The 'Medium' Date format and the 'Long' Time format is used.

Also see the "Current Date/Time Result Variables" section of that Help page for more $RVs that represent current time components.


Caller's Telephone Number (if available).


(direct link to the "Script Design" -> "Result Variables" section: http://www.voiceguid...ltvariables.htm )

#9 ThaoHuynh 13 July 2017 - 07:01 PM

It worked. Thank you so much.


Can i re-use a default string in URL address in Web Service Module?


ie: URL address = $RV[First WS] + "/OAuth/Token" 

#10 SupportTeam 13 July 2017 - 07:28 PM

Can i re-use a default string in URL address in Web Service Module?




After a $RV is created there are no limits on how many times it can be used for the remainder of the call.

#11 ThaoHuynh 13 July 2017 - 08:45 PM

So i must create a $RV to return the default string. Please give me a solution.

#12 SupportTeam 14 July 2017 - 12:46 AM

Evaluate Expression module can be used to create a new $RV (there are many other ways)


Specify this as the expression to evaluate:




and specify this in the 'Save result to the following Result Variable" :




then the URL you specified will be accessible using:



#13 ThaoHuynh 27 July 2017 - 01:45 PM

I would like to branch to other scripts and calling subscrips. Can i get result variables in mainscript from subcripts?

Thank you for your support.

#14 SupportTeam 27 July 2017 - 01:57 PM

Yes. Once a $RV has been created it can be used for remainder of the call from any script running on that line. Jumping/returning to new/previous scripts/subscripts does not affect the $RVs


(And 'Global' $RVs persist forever, and can be used by any script on any line)

#15 ThaoHuynh 16 August 2017 - 01:29 PM

Hi VG Team,


I added sound files to play in scripts. However when i tested this script using LinPhone in another machine, these sound files are unclear and different tone in original file (but these content are the same).


I attached my sound files. Please check it.


Thank you for you support

#16 SupportTeam 16 August 2017 - 01:46 PM

The sound files were not attached. Can you please .ZIP up the sound files and try attaching again.


If you could attach the VoiceGuide trace files that capture the call then this would also assist in determining the issue.

#17 ThaoHuynh 16 August 2017 - 01:53 PM

This is my sound files.

#18 SupportTeam 16 August 2017 - 02:37 PM

The sound files are .WAV in "16-bit 16kHz PCM" format.


16kHz is not a supported format. Please see: http://www.voiceguid.../soundfiles.htm


As this is a G711 VoIP based system then the best format to use would most likely be "8-bit 8kHz ULaw" format. "8-bit 8kHz ULaw" format is what is transmitted on most VoIP/SIP connections. So if your sound files are recorded in "8-bit 8kHz ULaw" then the sound data bytes from your sound file will be the actual bytes transmitted over the SIP connection - giving you exact control over sound transmitted to caller.


Please ask the source that provided these sound files to supply the sound files in the .WAV "8-bit 8kHz ULaw" format.


In the meantime please see attached. That .ZIP contains your sound files converted to "16-bit 8kHz PCM" format.

These sound files will work with VoiceGuide, but as they are converted from your 16kHz files they will not sound as good as the ULaw sound files generated from original high quality recordings.


If you arrange to have sound files provided to you in .WAV "8-bit 8kHz ULaw" format from the original source then this will result in best sound quality.


(You can use WireShark http://www.wireshark.org to confirm what is the actual sound encoding format used on your SIP connection)

  • Attached File  8kHz.zip   421.23KB   3 downloads

#19 ThaoHuynh 16 August 2017 - 02:56 PM

Thank you so so much. It will take a lot of time to request new sound files, so what tool can convert "6-bit 16kHz PCM" to "16-bit 8kHz PCM" format?

#20 SupportTeam 16 August 2017 - 06:09 PM

Please see the small sound player .EXE that is copied into VoiceGuide directory. It can save files in different format.

Use "File" -> "Save As" menu and click the "Change" button to select format before changing.