voiceXML, basic flow control. Goto tag does not work

639 views Asked by At

I have wrote this basic voiceXML application, but I am stuck for hours on a basic flow control issue. The goto tag (<goto nextitem="countryState" />) does not work. I keep staying in the loop for variable name offset. Any help would be great.

Thanks in advance.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml" xmlns:bevocal="http://www.bevocal.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
    <form>
        <field name="offset">
            <grammar src="map.xml#cities" type="application/grammar-xml"/>
            <prompt>
                What city would you like the time for?
            </prompt>

            <catch event="noinput nomatch" count="1">
                Please say the city that your are living at. For example, chicago, los angeles or new york city
                <reprompt/>
            </catch>

            <catch event="noinput nomatch" count="2">
                Apparently the provided city is not in our system. Lets try something different.
                <goto nextitem="countryState" />
                <disconnect/>
            </catch>

            <filled>
                <if cond="offset == '-8'">
                    <prompt>You are living in UTC offset of <value expr="offset"/></prompt>

                    <elseif cond="offset == '-7'"/>
                    <prompt>You are living in UTC offset of <value expr="offset"/></prompt>

                    <elseif cond="offset == '-6'"/>
                    <prompt>You are living in UTC offset of <value expr="offset"/></prompt> 

                    <elseif cond="offset == '-5'"/>
                    <prompt>You are living in UTC offset of <value expr="offset"/></prompt>

                    <elseif cond="offset == '-3.5'"/>
                    <prompt>You are living in UTC offset of <value expr="offset"/></prompt>
                </if>
            </filled>
        </field>

        <field name="formatTime">
            <prompt>
                Twelve hour or twenty four hour clock?
            </prompt>
            <grammar type="application/x-nuance-gsl">
                [[twelve (twenty four)] ?hour]
            </grammar>
        </field>

        <script>
            <![CDATA[
            var d = new Date();
            function calcTime() {
                // create Date object for current location
                var d = new Date();

                // convert to msec
                // subtract local time zone offset
                // get UTC time in msec
                var utc = d.getTime() - (d.getTimezoneOffset() * 60000);

                // create new Date object for different city
                // using supplied offset
                var nd = new Date(utc + (3600000 * (countryState ? countryState : offset)));

                // return time
                if (formatTime == "twelve hour") {
                    return "" + ((nd.getHours() > 12) ? (nd.getHours() - 12) : (nd.getHours()) ) + " and " + nd.getMinutes() + " minutes.";
                } else {
                    return "" + nd.getHours() + " and " + nd.getMinutes() + " minutes";
                }
            }
          ]]> 
        </script>

        <block>
            <prompt>Current time is <value expr="calcTime()" /> </prompt>
            <prompt>Thank you. Bye.</prompt>
            <disconnect/>
        </block>


        <field name="countryState">
            <prompt>
                If you are in U.S., which U.S. state your are currently living in? If you are outside of U.S., which country you are currently living in?
            </prompt>

            <grammar src="map.xml#countryState" type="application/grammar-xml"/>

            <filled>    
                <if cond="countryState == '+8'">
                    <prompt>You are living in UTC offset of <value expr="countryState"/></prompt>

                    <elseif cond="countryState == '+1'"/>
                    <prompt>You are living in UTC offset of <value expr="countryState"/></prompt>

                    <elseif cond="countryState == '+0'"/>
                    <prompt>You are living in UTC offset of <value expr="countryState"/></prompt>

                    <elseif cond="countryState == '-6'"/>
                    <prompt>You are living in UTC offset of <value expr="countryState"/></prompt>
                </if>
                <goto nextitem="formatTime" />
            </filled>
        </field>
    </form>
</vxml>
0

There are 0 answers