This is an old revision of the document!

< field >

The < field > element declares an input field in a form and prompts the user for values that match a grammar.

modal="true" | "false"
saveutterance="true" | "false">
child elements
nameThe name attribute defines the name of the field item variable that holds the matched user input. This attribute is required.
exprThe expr attribute is the initial value of the field item variable. This field will be visited only if the expression evaluates to undefined. This attribute is optional and defaults to undefined.
condThe cond attribute is a Boolean condition that must evaluate to true in order for this field to be visited. This attribute is optional and defaults to true.
typeThe type attribute specifies a built-in grammar. This attribute is optional and can be used as an alternative to the <grammar> element.
slotThe slot attribute is the name of the grammar slot used to populate the field item variable for mixed initiative dialog. This attribute is optional and defaults to the variable name.
modalThe modal attribute is set to true if only the field's grammars are enabled. Otherwise, all active grammars are enabled. This attribute is optional and defaults to false.

The <field> shadow variable (name$) has the following properties after the field is filled in by user input. These properties are available in object application.lastresult$ as well: * name$.utterance – a raw string of words that were recognized. * name$.inputmode – a user input type, either dtmf or voice. * name$.interpretation – an interpretation for this result. * name$.confidence – a recognition confidence level. Floating point value between 0 to 1.0.

The following built-in types are supported for the DTMF input mode: boolean

  1. The grammar for affirmative and negative phrases. It returns “true” for yes and “false” for nodigits.
  2. The grammar for a string of digits from spoken or DTMF input. It returns the string of digits number.
  3. The grammar for numbers. It returns a string of digits from 0 to 9, and may optionally include a decimal point (“.”) and/or a plus or minus sign.
  4. The grammar text. It use the SpeechToText ressources to convert the users speaking into text. The text is set in the variable content.

The following built-in type parameters can be parameterized with this syntax:


For example, we can assign a DTMF sequence for a Boolean type:

<field name="mychoice" type="boolean?y=5;n=6">
booleany - the DTMF sequence for an affirmative answer. n - the DTMF sequence for a negative answer.
digitslength - exact number of digits.
numberlength - exact number of numbers.
textlang - the speech language to use.

If there is a conflict among these parameters, an error.badfetch event is thrown.

The built-in types supported depends on the ASR installed and configured. Refer to the ASR provider.

<audio>, <catch>, <enumerate>, <filled>, <grammar>, <help>, <link>, <noinput>, <nomatch>, <option>, <prompt>, <property>, <return>, <value>
<?xml version="1.0"?>
<vxml version="2.0" xmlns="">
 <form id="testfield">
   Welcome to the restaurant.
<!-- field using built in grammar with digits type -->
  <field name="built_in_gram1" type="number">
   <prompt> How many people you have? </prompt>
    Here is a table for <value expr="built_in_gram1"/> people.
    Have a seat.
    <goto nextitem="built_in_gram2" />
<!-- filed using built in grammar with boolean type -->
  <field name="built_in_gram2" type="boolean">
   <prompt> Are you ready for ordering now ? </prompt>
    <if cond="built_in_gram2 == 'true'">
     <goto nextitem="optionlist" />
    <elseif cond="built_in_gram2 == 'false'"/>
     <goto nextitem="notready" />
<!-- filed using option list -->
  <field name="optionlist">
    Which entree would you like, baked potato, french fries?
   <option dtmf="1" value="baked potato">baked potato</option>
   <option dtmf="2" value="french fries">french fries</option>
    ok. <value expr="optionlist"/> as entree.
    <goto nextitem="explicit_gram1" />
<!-- filled using explicit grammar -->
  <field name="explicit_gram1">
    Here is the main dishes you could choose from,
    Vegetarain delight, Prime Rib, Baked clams
   <grammar type="text/x-grammar-choice-dtmf" mode="dtmf">
    1 {Vegetarain delight} |
    2 {Prime Rib} |
    3 {Baked clams}
    Good choice.
    <value expr="explicit_gram1"/>
    is my favorite as well.
    <goto nextitem="ordertaken" />
  <block name="goodbye">
   good bye
  <block name="ordertaken">
   Please wait. Your meal will be ready shortly.
  <block name="notready">
   Ok. Take your time and call back later.
  • developer_guide/voicexml_references/elements/field.1490106061.txt.gz
  • Last modified: 2017/03/21 14:21
  • by borja