Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.40 prompt

Element type

prompt

Attributes

bargein | bargeintype (2.0) | cond | count | timeout | xml:lang (2.0)

Parents

block | catch | error | field | filled | help | if | initial | menu | noinput | nomatch | object | record | subdialog | transfer

Children

PCDATA | audio | break | emphasis | enumerate | mark | paragraph | phoneme | prosody | say-as | sentence | value | voice

Description

Instructs the interpreter to render its contents as audio to the caller.

DTD

<!ELEMENT prompt (%audio; | %tts;)* >
<!ATTLIST prompt
  bargein     %boolean;     #IMPLIED
  bargeintype %bargeintype; #IMPLIED
  cond        %expression;  #IMPLIED
  count       %integer;     #IMPLIED
  xml:lang    NMTOKEN       #IMPLIED
  timeout     %duration;    #IMPLIED >

Language model

40

Attributes

  • bargein : boolean

    Controls whether the user can interrupt the prompt. When bargein is allowed and the user interrupts the current prompt, any other queued prompts will also be interrupted. The default value is true. Alternatively, in the absence of a bargein attribute, the bargein property can be used.

  • bargeintype : (energy | speech | recognition)

    Determines what constitutes a bargein. The choices are: energy (when the caller's audio-signal content is over a certain energy threshold), speech (when the caller's audio-signal content is interpreted as speech), or recognition (when the caller's audio-signal matches an active grammar).

  • cond : expression

    A condition to evaluate, and if true, play the prompt. Default is true.

  • count : integer

    If defined, the prompt with a count set to a number that is not greater than the current reprompt counter and whose count is closest in value to the reprompt counter will be played.

  • timeout : duration

    The time to wait for user input before a noinput event is thrown. The default noinput timeout is platform-specific.

  • xml:lang : NMTOKEN

    Defines the language dictionary to be used in this grammar (e.g. en-US for US English). If the language specified is not supported on the VoiceXML platform, the interpreter will throw an error.unsupported.language event.

Children

  • audible and tts

    The content to be rendered as audio.

Examples

Example 3-46 A prompt containing content to be rendered as audio

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form>
    <block>
      <prompt>
        Please <emp>say</emp> your name.
      </prompt>
    </block>
  </form>
</vxml>

Example 3-47 A prompt containing an audio with an alternate tts

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form>
    <block>
      <prompt bargein="true"> 
        <audio src="welcome.wav">
          <emphasis>Welcome</emphasis> to Voice Portal. 
        </audio> 
      </prompt>
    </block>
  </form>
</vxml>

Example 3-48 A prompt with bargein set to true

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form>
    <block>
      <prompt bargein="true"> 
        Welcome to the Bird Seed Emporium. 
        <audio src="https://www.example.com/birdsounds/thrush.wav"/> 
        We have 250 kilogram drums of thistle seed for 
        <say-as class="currency">$299.95</say-as> 
        plus shipping and handling this month. 
        <audio 
          src="https://www.example.com/birdsounds/mourningdove.wav"/>
      </prompt>
    </block>
  </form>
</vxml>

In Example 3-49, the first time the flavor field is visited, the prompt "What is your favorite flavor?" will be rendered followed by "Say chocolate, vanilla, or strawberry". If the caller didn't say anything that matched the grammar, the field would be revisited, except the second and third time, only the prompt "Say chocolate, vanilla, or strawberry" will be rendered. After the third attempt, if the field's grammar is still not matched, no prompts will be rendered.

Example 3-49 The count attribute allowing different prompts to be played when reprompting

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form>
    <field name="flavor"> 
      <grammar>vanilla|chocolate|strawberry</grammar> 
      <prompt count="1">What is your favorite flavor?</prompt> 
      <prompt count="3">
        Say chocolate, vanilla, or strawberry.
      </prompt> 
      <help>Sorry, no help is available.</help> 
    </field>
  </form>
</vxml>

Example 3-50 uses the cond attribute for a prompt. If the random value r is less than .5, the prompt "Would you like to hear another elephant joke?" will be rendered, otherwise the prompt "For another joke, say yes. To exit, say no" will be rendered.

Example 3-50 Using the cond attribute to control rendered audio

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml>
  <form id="another_joke"> 
    <var name="r" expr="Math.random()"/> 
    <field name="another" type="boolean"> 
      <prompt cond="r < .5"> 
        Would you like to hear another elephant joke? 
      </prompt> 
      <prompt cond="r >= .5"> 
        For another joke say yes. To exit, say no.
      </prompt>
      <filled> 
        <if cond="another"> 
          <goto next="#pick_joke"/> 
        </if> 
      </filled> 
    </field> 
  </form>
</vxml>

Example 3-51 Using the timeout attribute

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form>
    <block>
      <prompt count="2" timeout="120s">
        Please choose the color of your new nineteen twenty-four
        Ford Model T.
        Possible colors are black, black, or black. 
        Please take your time.
      </prompt>
    </block>
  </form>
</vxml>
  • + Share This
  • 🔖 Save To Your Account