Plum DEV Documentation
voicexml:tags:form

<form>

Forms are the key components of VoiceXML documents. A form contains:

  • A set of form items, elements that are visited in the main loop of the form interpretation algorithm. Form items are subdivided into input items that can be “filled” by user input and control items that cannot.
  • Declarations of non-form item variables.
  • Event handlers.
  • “Filled” actions, blocks of procedural logic that execute when certain combinations of input item variables are assigned.

Attributes

id The name of the form. If specified, the form can be referenced within the document or from another document. For instance <form id=“weather”>, <goto next=“#weather”>. Please note that this attribute does not allow for any white space.
scope The default scope of the form's grammars. If it is dialog, then the form grammars are active only in the form. If the scope is document, then the form grammars are active during any dialog in the same document. If the scope is document and the document is an application root document, then the form grammars are active during any dialog in any document of this application. Note that the scope of individual form grammars takes precedence over the default scope; for example, in non-root documents, given a form with the default scope “dialog” and a form grammar with the scope “document”, that grammar is active in any dialog in the document.

Notes

Please keep in mind that the id attribute for this tag does not allow for any white space.

Example

<?xml version="1.0"?>
<vxml version="2.0">
  <form id="firstform">
    <block>
      <prompt>
        Welcome! Let's move to a form where we gather some input.
      </prompt>
      <!-- A "#" symbol followed by an identifier specifies a -->
      <!-- form or menu ID to jump to. -->
      <goto next="#thirdform"/>
    </block>
  </form>

  <form id="secondform">
    <block>
      <prompt>
        You've made it to the final form! Goodbye.
      </prompt>
      <disconnect/>
    </block>
  </form>

  <form id="thirdform">
    <field name="lucky_number" type="digits?length=1">
      <prompt>
        Enter your lucky number.
      </prompt>
      <filled>
        <prompt>
          Your lucky number is <value expr="lucky_number"/>. Let's move on to another form.
        </prompt>
        <goto next="#secondform"/>
      </filled>
      <catch event="nomatch noinput" count="1,2">
        <prompt>
          Your lucky number should be 1 digit. Let's try again.
        </prompt>
        <reprompt/>
      </catch>
      <catch event="nomatch noinput" count="3">
        <prompt>
          I guess you don't have a lucky number. Let's move on to the next form anyways.
        </prompt>
        <goto next="#secondform"/>
      </catch>
    </field>
  </form>
</vxml>

The output of the above script would be:

Computer: Welcome! Let's move to a form where we gather some input.
Computer: Enter your lucky number.
User: <user enters: 3>
Computer: Your lucky number is 3. Let's move on to another form.
Computer: You've made it to the final form! Goodbye.

Child Tags

Parent Tags