Main Menu
|
Section Menu
|
Syllabus
|
Previous
|
Next |
Grammars | Page 3 of 6 |
A grammar defines the set of valid expressions that a user can say when interacting with a voice application. Each interactive dialog in an application references one or more grammars using one or more grammar elements.
<vxml version="2.0"> <form id="form1"> <field name="field1"> <grammar> <!-- grammar goes here --> </grammar> </field> </form> </vxml> |
You can also use the link element to define commands that behave consistently within a VoiceXML document or throughout your application.
<vxml version="2.0"> <link event="mycompany.myapp.myevent1"> <grammar> <!-- grammar goes here --> </grammar> </link> </vxml> |
Specifying the grammar mode
Traditional IVR applications support touch-tone input also known as DTMF input.When constructing grammars, you will get superior performance and compliance with the VoiceXML specification if you separate your DTMF from your voice grammars. The following example shows two simple GSL grammars. The first allows the user to say the name of a department. The second allows the user to enter a digit representing the desired department.
<grammar type="application/x-gsl" mode="voice"> <![CDATA[ [ [sales] {<dept "010">} [marketing] {<dept "020">} [engineering] {<dept "030">} [(public relations) (p r)] {<dept "040">} ] ]]> </grammar> |
<grammar type="application/x-gsl" mode="dtmf"> <![CDATA[ [ [dtmf-1] {<dept "010">} [dtmf-2] {<dept "020">} [dtmf-3] {<dept "030">} [dtmf-4] {<dept "040">} ] ]]> </grammar> |
The type attribute indicates to the VoiceXML interpreter the format of the grammar. In the previous example, the value "application/x-gsl" indicates that the grammar is in the Nuance GSL format. The mode attribute indicates to the VoiceXML interpreter if the grammar is a voice or DTMF grammar.
Main Menu
|
Section Menu
|
Syllabus
|
Previous
|
Next |