initial element
VoiceXML 2.0
Prompts the user for form-wide information.

Syntax

<initial
cond = "ECMAScript_Expression"
expr = "ECMAScript_Expression"
name = "string"
/>

Attributes
cond
A condition that must evaluate to true for the element to be selected by the form interpretation algorithm (FIA). If this condition evaluates to false or the variable associated with the name attribute has a defined value, the element is not visited.
expr
An ECMAScript expression that supplies the initial value for the form item variable associated with this element. If the expression evaluates to something other than null or ECMAScript undefined, the element will not be visited until the form item variable is explicitly cleared.
name
The name of the initial element's form item variable. If the attribute is not specified, the interpreter creates a hidden, anonymous variable to store the result.

The initial element exposes the following shadow variables.

name$.recording
The variable that stores the recorded utterance when the recordutterance property is set to true. Like the variable associated with the name attribute of the record element, this shadow variable stores a reference to the recording within the scope of the dialog that contains the initial. The recording referenced by the recording shadow variable is in the format specified by the recordutterancetype property. For information on persisting the recording to a Web server see the utterance recording tutorial.
name$.recordingsize
The size of the utterance recording referenced by the recording shadow variable, in bytes.
name$.recordingduration
The duration of the utterance recording referenced by the recording shadow variable, in milliseconds.
Parents
form

Children
audio, catch, enumerate, error, help, link, noinput, nomatch, prompt, property, value

Remarks
The initial element is useful in a mixed initiative dialog that prompts the user for form-wide information - before the user enters the directed mode where each field element is solicited individually. To use the initial element, you need a grammar with form scope that can match user utterances in response to the initial element's prompts. The initial element behaves like a field in that it can have prompt elements, event handlers, and event counters, but it does not have its own grammar or a filled element.
The Tellme VoiceXML interpreter supports recording during recognition within an initial element in revision 3 and later. For further information, see the utterance recording tutorial.
Examples

The following example prompts the user to specify the name of a cartoon and a day of the week to record the program. The user can say things like "X Men on Thursday", "Scooby Doo", or "Sunday". The first utterance fills both the which_weekday and which_cartoon form item variables. The second utterance fills just the which_cartoon form item variable, and the third utterance fills just the which_weekday form item variable. In the first case the VoiceXML interpreter executes the form-level block and navigates to the Platform main menu. In the second and third cases, the user is further prompted for the weekday and cartoon respectively to satisfy the corresponding field's form item variables. Only then is the block named 'done' executed and the application terminated. If the user fails to fill the which_weekday or which_cartoon form item variables after two attempts (nomatch, noinput), the code satisfies the initial element's guard condition. This causes the VoiceXML interpreter to execute the fields corresponding to each of the form item variables.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
 <form id="cartoons">
  
  <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>
              <ruleref uri="#Cartoon"/>
              <tag>a = rules.latest();</tag>
            </item>
          </one-of>
          <tag>out.which_cartoon = a;</tag>
        </item>
        <item>
          <one-of>
            <item>
              <ruleref uri="#Weekday"/>
              <tag>b = rules.latest();</tag>
            </item>
          </one-of>
          <tag>out.which_weekday = b;</tag>
        </item>
        <item>
          <one-of>
            <item>
              <item>
                <ruleref uri="#Cartoon"/>
                <tag>a = rules.latest();</tag>
              </item>
              on
              <item>
                <ruleref uri="#Weekday"/>
                <tag>b = rules.latest();</tag>
              </item>
            </item>
          </one-of>
          <tag>out.which_cartoon = a; out.which_weekday = b;</tag>
        </item>
      </one-of>
    </rule>

    <rule id="Cartoon" scope="private">
      <one-of>
        <item>
          <one-of>
            <item>
              scooby
            </item>
            <item>
              scooby
              doo
            </item>
          </one-of>
          <tag>out = "scooby";</tag>
        </item>
        <item>
          batman
          beyond
          <tag>out = "batman_beyond";</tag>
        </item>
        <item>
          simpsons
          <tag>out = "simpsons";</tag>
        </item>
        <item>
          futurama
          <tag>out = "futurama";</tag>
        </item>
        <item>
          x
          men
          <tag>out = "x_men";</tag>
        </item>
        <item>
          batman
          <tag>out = "batman";</tag>
        </item>
        <item>
          <one-of>
            <item>
              power_puff
              girls
            </item>
            <item>
              power
              puffs
            </item>
          </one-of>
          <tag>out = "power_puff";</tag>
        </item>
        <item>
          <one-of>
            <item>
              dexter
            </item>
            <item>
              dexter's
              laboratory
            </item>
          </one-of>
          <tag>out = "dexter";</tag>
        </item>
      </one-of>
    </rule>

    <rule id="Weekday" scope="private">
      <one-of>
        <item>
          monday
          <tag>out = "mon";</tag>
        </item>
        <item>
          tuesday
          <tag>out = "tues";</tag>
        </item>
        <item>
          wednesday
          <tag>out = "wed";</tag>
        </item>
        <item>
          thursday
          <tag>out = "thurs";</tag>
        </item>
        <item>
          friday
          <tag>out = "fri";</tag>
        </item>
        <item>
          saturday
          <tag>out = "sat";</tag>
        </item>
        <item>
          sunday
          <tag>out = "sun";</tag>
        </item>
      </one-of>
    </rule>

  </grammar>

 
  <initial name="init_cartoons">
   <prompt>
     what cartoon would you like to
      record and on what day of the week? 
   </prompt>

   <nomatch count="1">
     i'm sorry, i didn't understand that
    
    <reprompt/>
   </nomatch>
  
   <nomatch count="2">
     i'm sorry, i still didn't understand that.
     let's take this step by step 
     <!-- let's just go and ask  -->
    <assign name="init_cartoons" expr="true"/>
   </nomatch>
 
   <noinput>
    please say a cartoon you would like to
     record and what day of the week you would like to
     record it on. for example, say power puffs on
     tuesday. 
    <reprompt/>
   </noinput>
   
   <noinput count="2">
     i'm sorry, i still didn't hear you.
     let's take this step by step 
     <!-- let's just go and ask  -->
     <assign name="init_cartoons" expr="true"/>
   </noinput>
  </initial>
 
  <field name="which_cartoon">
   <prompt>
     which cartoon would you like to record? for
     example, you can say batman, power puff girls, or
     dexter's laboratory
    
   </prompt>
    
   <nomatch count="1">
     i didn't catch that 
    <reprompt/>
   </nomatch>
    
   <nomatch count="2">
     i'm not sure what you just said. 
    <reprompt/>
   </nomatch>
  
   <nomatch count="3">
     sorry.  i'm just not getting it 
     exiting 
    <exit/>
   </nomatch>
  
   <noinput>
     which cartoon would you like to record? 
     please say batman, power puff girls, or
     dexters
    <reprompt/>
   </noinput>
   <filled>
    <if cond="which_cartoon == 'powerpuffs'">
      all right!! 
      you said
     <value expr="which_cartoon"/>
     <else/>
      oh 
    </if>
   </filled>
  </field>
   
  <field name="which_weekday">
   <prompt>
     what day of week would you like to record
     your cartoon?
    
    
   </prompt>
    <nomatch count="1">
      I didn't catch that 
      Say  a weekday, for example, say monday
     
   </nomatch>
      
   <nomatch count="2">
     I still didn't catch that 
     Please say a weekday, you wish to record on.
    
    <reprompt/>
   </nomatch>
  
   <nomatch count="3">
     I'm sorry.  I really can't understand a
     word you are saying 
     exiting 
    <exit/>
   </nomatch>
 
   <noinput>
     please say a weekday 
    <reprompt/>
   </noinput>
  
   <filled>
    <if cond="which_weekday == 'monday'">
      you got it 
    <else/>
      of course 
    </if>
   </filled>
  </field>
 
  <block name="done">
    recording <value expr="which_cartoon"/>
    on <value expr="which_weekday"/>
   <exit />
  </block>
 </form>
</vxml>


See Also
Using Mixed Initiative
[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers