else
Provides the final alternative in an if construct.
The following example request the name of a flower from the user, compares the value returned by the grammar, and plays back audio about the flower.
<?xml version="1.0"?>
<vxml version="2.1"
xmlns="http://www.w3.org/2001/vxml">
<link event="event.exit">
<grammar mode="voice"
root="root_rule"
tag-format="semantics/1.0"
type="application/srgs+xml"
version="1.0"
xml:lang="en-US">
<rule id="root_rule" scope="public">
<one-of>
<item>
quit
</item>
</one-of>
</rule>
</grammar>
<grammar mode="dtmf"
root="root_rule"
tag-format="semantics/1.0"
type="application/srgs+xml"
version="1.0">
<rule id="root_rule" scope="public">
<one-of>
<item>
*
*
</item>
</one-of>
</rule>
</grammar>
</link>
<catch event="event.exit">
<exit />
</catch>
<link event="help">
<grammar mode="voice"
root="root_rule"
tag-format="semantics/1.0"
type="application/srgs+xml"
version="1.0"
xml:lang="en-US">
<rule id="root_rule" scope="public">
<one-of>
<item weight="0.5">
help
</item>
<item weight="0.5">
mercy
</item>
</one-of>
</rule>
</grammar>
<grammar mode="dtmf"
root="root_rule"
tag-format="semantics/1.0"
type="application/srgs+xml"
version="1.0">
<rule id="root_rule" scope="public">
<one-of>
<item>
0
</item>
</one-of>
</rule>
</grammar>
</link>
<form id="pick_flower">
<field name="flower">
<prompt>
Pick a flower
</prompt>
<grammar mode="voice"
root="root_rule"
tag-format="semantics/1.0"
type="application/srgs+xml"
version="1.0"
xml:lang="en-US">
<rule id="root_rule" scope="public">
<one-of>
<item>
<one-of>
<item>
rose
</item>
<item>
roses
</item>
</one-of>
<tag>out.flower = "rose";</tag>
</item>
<item>
<one-of>
<item>
violet
</item>
<item>
violets
</item>
</one-of>
<tag>out.flower = "violet";</tag>
</item>
<item>
<one-of>
<item>
grass
</item>
<item>
grasses
</item>
</one-of>
<tag>out.flower = "grass";</tag>
</item>
<item>
<one-of>
<item>
tulip
</item>
</one-of>
<tag>out.flower = "tulip";</tag>
</item>
</one-of>
</rule>
</grammar>
<!-- handle the first noinput for this field -->
<catch event="noinput nomatch">
I'm sorry. I didn't get that.
<throw event="help"/>
</catch>
<!-- handle all help events for this field -->
<help>
Say rose, violet, grass, tulip. Say quit at any time to exit.
</help>
<filled>
<if cond="'rose' == flower">
roses are red
<elseif cond="'violet' == flower"/>
violets are blue
<elseif cond="'tulip' == flower"/>
tulips come in many colors
<else/>
the grass is greener over here.
</if>
<clear/>
</filled>
</field>
</form>
</vxml>
Community Additions
ADD
Show: