How to invoke state table from VXML application with data?



Question


How can I pass parameters from VXML to a state table and also receive some variable updates like SystemVariables from the state table?

Answer


The VXML application can invoke the method of invokeStateTable and defines in the <param name="setParams"> tag and <param name="setApplicationData"> tag all the parameters:
  • From VXML to state tables
  • From state table back to VXML

For example, the following VXML application passes a variable string "ABC" to the state table and receives the value of SV139 from the state table --


The vxml file: 

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml xmlns="http://www.w3.org/2001/vxml
      xsi:schemaLocation="http://www.w3.org/2001/vxml
                          http://www.w3.org/TR/voicexml20/vxml.xsd"                               version="2.0">

<var name="from_VXML" expr="'ABC'" />        
<var name="to_VXML"   expr="'###'" />      
<form id="state_table">

<object name="st1" classid="method://com.ibm.wvr.vxml2.NativeAppSupport/invokeStateTable" 
codetype="javacode-ext">  


<param name="setName" value="VXML2_ST" /> 


<param name="setEntryPoint" value="begin" />


<param name="setParms" expr="new Array(from_VXML, to_VXML)" />  


<param name="setApplicationData" expr="new Array(from_VXML,to_VXML)" />  


<filled> 
      <log> the first parm is <value expr="st1.parms[0]" /> </log>    
      <log> the second parm is <value expr="st1.parms[1]" /> </log>   
</filled>


</object>
</form> 
</vxml> 

The state table
# =================================================
# Description
DESCRIPTION("Welcome to IBM AIX DirectTalk/6000");
#
# =================================================
# Prompt Directory
PROMPT_DIRECTORY(test_Welcome);
#
# =================================================
# Entry Point(s)
ENTRY_POINT(begin,answer1); #
# =================================================
# Variables
INPUT STRING from_VXML,
STRING to_XML;
LOCAL STRING log_string;
#
# =================================================
# Actions
answer1:

AnswerCall();                                                               


"play 'Welcome' segment"


PlayPrompt("TRUE", Welcome);


AssignData(log_string, "ASSIGN", "FILE=test_VXML2:");


AssignData(log_string, "CONCATENATE", log_string, from_VXML);


LogEvent(VAR_UNDEFINED, log_string);


"read the input string as char"


PlayPrompt("TRUE", read_char,from_VXML);


"assign SV139 to to_VXML" 


AssignData(to_XML, "ASSIGN", SV139);


ExitStateTable(0);                                                          
===============================================

After the test call, the following messages can be found from the dtjflog output:
INFO: VXML: [......]: the first parm is ABC
INFO: VXML: [..... ]: the second parm is [hostname]
where [hostname] is the SV139 -- SystemName.