Part I: Developing Inbound Applications: DTMF Command | Gateway Tutorial
DTMF tones are the tones used in telephones for tone dialing. Traditionally, they are the only means user can interact with a telephony application.
The following provides the same functionality as the one in previous section except it uses DTMF tones for time zone selection.
<?xml version="1.0"?> <vxml version="1.0"> <%@ page import="java.util.Date" %> <%@ page import="java.text.SimpleDateFormat" %> <%@ page import="java.util.TimeZone" %> <% response.setHeader("Cache-Control","no-cache"); Date d = new Date(System.currentTimeMillis()); String tz = request.getParameter("tz"); TimeZone timez = null; if ("1".equals(tz)) timez = TimeZone.getTimeZone("America/Los_Angeles"); else if ("2".equals(tz)) timez = TimeZone.getTimeZone("America/Denver"); else if ("3".equals(tz)) timez = TimeZone.getTimeZone("America/Chicago"); else if ("4".equals(tz)) timez = TimeZone.getTimeZone("America/New_York"); SimpleDateFormat f; if (timez != null) { f = new SimpleDateFormat("hh:mm a, zzzz"); f.setTimeZone(timez); } else { f = new SimpleDateFormat("hh:mm a"); } %> <form id="td"> <field name="tz"> <prompt timeout="10s"> <block> <audio src="audio/welcome.wav"/> <%= f.format(d) %> <audio src="audio/which_timezone_dtmf.wav"/> </block> </prompt> <dtmf> 1 | 2 | 3 | 4 </dtmf> <filled> <submit next="/td/timeofday.jsp" namelist="tz"/> </filled> </field> </form> </vxml>
Save the content as timeofday.jsp. It is OK to overwrite the original content, we'll visit that again later. Also record a new voice prompt, such as "press 1 for pacific time, ..., press 4 for eastern time", and save it as which_timezone_dtmf.wav under <tddir>/webapps/audio.
Restart the Gateway and call in the test again.
Download the sample code: timeofday_step5.zip.