Вы находитесь на странице: 1из 19

Dynamic VoiceXML and JSP

Overview
Dynamic VoiceXML
Retrieving information from the Web
Changing information on the Web
Dynamic generation of VoiceXML documents
Dynamic grammar generation

From static to dynamic VoiceXML
Aim to create Web applications that emit standards-
compliant VoiceXML.
Similar to visual Web - static HTML pages have been
replaced over time by server-side Web application
frameworks that emit HTML.
Abstract the details of back-end integration, as well as
the underlying business logic that determines the
transitions among different stages in an application,
Helps developers integrate user tasks into larger
applications.
Move from voice-specific programming model to one in
which voice interaction is authored as a specialized
view that binds to a common underlying Web
application.
Web server e.g. Apache Tomcat
Scripting language e.g. Java Server Pages (JSP)
Dynamic VoiceXML
Types of transaction
Retrieving information e.g. users name, balance,
recent transactions
Changing information e.g. change pin, transfer funds
Getting items from a database to create a recognition
grammar e.g. account types for a particular customer
Processes
1. The system submits the digit string to a web server
using <submit>
2. The web server invokes a JSP script.
3. The script makes a connection to a database using
the JDBC-ODBC bridge.
4. A record is retrieved from the database.
5. Items from the retrieved database record are
incorporated into dynamically generated VoiceXML
code.
Retrieving information
Database: bank.mdb

Getting the users name
userdetails.vxml
userdetails.jsp

Getting balance
balance.vxml
balance.jsp

Recent transactions
transactions.vxml
transactions.jsp
<submit> example
<field name = pin" type="digits">
<prompt>
what is your pin?
</prompt>
</field>

<filled>
<submit next="http://localhost:8080/banking/balance.jsp"
namelist=pin />
</filled>


Note: if more than one value has been elicited, the namelist
attribute can be used to specify which values to elicit
userdetails.jsp
vxml file with embedded JSP e.g.

<?xml version="1.0"?>
<vxml version=2.0">
<form>
etc.

<%
// JSP code
// set up variable to obtain and store the user id
String pin;
// etc.

//create the SQL query
String sqlStatement =("SELECT * FROM Customer where (cust_pin)='"
+pin+"';");
%>

</vxml>
Getting data for Dynamic Output
if(rs.next())
{
//set up variables to contain the database fields data
String firstname;
String lastname;
// etc.

// obtain and print out the record of the database.
do
{
firstname = rs.getString(2);
lastname = rs.getString(3);
// etc.
}while (rs.next()); } //end of if
Dynamic output
can go here
Dynamic Output
//set up dynamic vxml
%>

<prompt>
Hello <%=firstname%> <%=lastname%>
</prompt>

<%
// continue with JSP
Retrieve values
from variables
holding database
values
Dynamic Grammars
A dynamic grammar is required when the recognition
vocabulary relevant to a prompt is not known in
advance
e.g. each person may have different account names, so
the recognition vocabulary should include only those
names that are relevant for the current user
The information would normally be kept in a database,
which would be regularly up-dated.
A static grammar that is created in advance would be
difficult to update every time the database is changed.
A better solution is to dynamically create the grammar
at run-time by consulting the most recent entries in the
database.
Creating dynamic grammars
Connecting to a database to retrieve a list of words to
be modelled.
Creating an inline or external grammar file that
contains these words.
Retrieving the list of words involves the use of a JSP
file to access a database and retrieve the required
words.
The grammar file requires a procedure to write the
words with the appropriate grammar format and to
call the grammar, as appropriate.
Example
account_details.vxml




accdetails.jsp




Asks user for pin
Dynamically creates grammars
for the fields destination and
source.
<! headers, imports, etc
<form>
<block>

<%
StringBuffer accgrammar = new StringBuffer();

//create the SQL query
// get accounts for this user

//set up variable to contain the database field data
String acc;
accdetails.jsp
do
{
acc = rs.getString(1);
accgrammar.append("<item>");
accgrammar.append(acc);
accgrammar.append("</item>");
}while (rs.next());

<field name="source">
<prompt>what is the source account?</prompt>
<grammar version="1.0" tag-format="semantics/1.0"
xml:lang="en-GB" mode="voice" root="source_acc">
<rule id="source_acc" scope="public">
<one-of>
<%=accgrammar.toString()%>
</one-of>
</rule>
</grammar>
</field>
<field name="source">
<prompt>what is the source account?</prompt>
<grammar version="1.0" tag-format="semantics/1.0"
xml:lang="en-GB" mode="voice" root="source_acc">
<rule id="source_acc" scope="public">
<one-of>
<item>Current</item>
<item>Savings</item>
</one-of>
</rule>
</grammar>
</field>
Dynamically generated output
Some more examples
balance.vxml
Asks for pin and account (can say savings, current or
all)
balance.jsp
Queries depending on which account (or all accounts)
Dynamically creates messages for balance for each
account

change_pin.vxml
Elicits values for old and new pin
change_pin.jsp
Updates pin

Example: recent transactions
transactions.vxml
asks for pin
transactions.jsp
Looks up last 5 transactions
Dynamically creates output e.g.

Transaction 1
<say-as interpret-as="vxml:currency">500.0</say-as>
from Current account to Savings account on
<say-as interpret-as="vxml:date">20050401</say-as>

Вам также может понравиться