Since the VoiceXML Forum Community Bulletin Board is increasingly besieged by spammers, going forward I’m going to cross post responses I submit there on this site so that interested parties (assuming there are any ;-)) can read them.
This response relates to the use of semantic interpretation in VoiceXML applications, something I have written on before. I hope readers find the exchange below helpful.
QUESTION:
Is there a way to map a response to a certain value? For instance, if the user says “yes,” “sure,” or “yeah” I’d like to put 1 in the database? If the user says “no,” “nope,” or “nah” I’d put 0.
ANSWER:
There are a couple of option open to you if all you are using is a simple yes/no grammar.
Option 1 = use the builtin “boolean” grammar type. By specifying a field type of “boolean”, an implicit grammar is created that should cover affirmative or negative responses for whataver language is being used. A boolean field returns a JavaScript string based on what the user says (e.g., yes=’true’ or no=’false’). You can convert this to a 1 or 0 using a simple if/else construct and a predefnied variable.
`</p>
...
</filled> `
Option 2 = you can use the </field `
This has the effect of filling the field named “F_1” with the value specified in the
</field>
...</p>
< ?xml version = "1.0"?>
<one -of>
</one>