Presentation is loading. Please wait.

Presentation is loading. Please wait.

VoiceXML: Events, Errors, and ECMAScript. Acknowledgements Prof. Mctear, Natural Language Processing, University.

Similar presentations


Presentation on theme: "VoiceXML: Events, Errors, and ECMAScript. Acknowledgements Prof. Mctear, Natural Language Processing, University."— Presentation transcript:

1 VoiceXML: Events, Errors, and ECMAScript

2 Acknowledgements Prof. Mctear, Natural Language Processing, http://www.infj.ulst.ac.uk/nlp/index.html, University of Ulster. http://www.infj.ulst.ac.uk/nlp/index.html

3 Events 1.Plain events – happen normally, involve special event handler 2.Error events - unexpected situations, may cause application to terminate Plain eventsError events cancel, help, exit (user)error.badfetch noinput, nomatch (user input)error.semantic connection.disconnect.hanguperror.noauthorization maxspeechtimeouterror.unsupported.builtin Note: how events are handled is platform-dependent

4 Default catch handlers Event TypeAction canceldon’t reprompt errorexit interpreter exitexit interpreter helpreprompt noinputreprompt nomatchreprompt maxspeechtimeoutreprompt connection.disconnectexit interpreter all othersexit interpreter

5 noinput, nomatch System does not detect any speech. This event is thrown when the timeout interval is exceeded (in IBM WebSphere Voice Toolkit the default timeout interval is 500 milliseconds). The user’s input does not match the recognition grammar. The default behaviour in the IBM WebSphere Voice Toolkit for this event is to output a message and then re-prompt. These (and other) default event handlers can be modified. Properties such as “timeout” can also be modified.

6 I did not understand what you said. Please answer the question again.

7 Shorthand elements Some common events, such as noinput, nomatch, help, and error have shorthand versions, e.g. I did not understand, please try again. I didn’t hear anything. Please speak a little louder. With counters:

8 Used to define application-specific events e.g. user has failed 3 times to enter valid id That is not a valid i d … Please check your i d. Goodbye

9 Event handlers and scope Event handlers can be defined at different scope levels Scope levels form a hierarchy. Event handlers defined in a higher scope level are inherited at lower scope levels within the hierarchy. A local event handler overrides or replaces an inherited event handler. If a local event handler has the same name as an inherited event handler, then the local event handler replaces the inherited event handler. The VoiceXML interpreter examines the following containers in the order listed to select an event handler: 1. Field 2. Dialog 3. Document 4. Application 5. Session

10 Tutorial Exercises: Error handling Aim: to explore events such as and and modify their default behaviours 1.Run the file ‘studentsystem1b.vxml’ and test how it behaves when a) You do not say anything; b) You say something that is not in the specified recognition vocabulary. 2.Modify the default behaviours for and using counters for alternative behaviours. 3.Define an application specific event using that causes the application to terminate with some form of explanation following an event such as repeated failure to elicit valid input. The event could be a third failure to elicit the user’s spoken input, with an event thrown such as “error.no_input”. This event can be caught, causing the system to transfer to a human operator. Include a prompt that explains what is happening. If transfer is not possible, then use or to cause the application to terminate.

11 What is ECMAScript? Used as the scripting language of VoiceXML for client- side processing, e.g. to validate user input (without requiring access to the server), or to dynamically generate values. VoiceXML variables are completely equivalent to ECMAScript variables. The “expr” and the “cond” attributes reference ECMAScript expressions. Escaping characters to conform to the rules of XML e.g. Or use the element e.g. <![CDATA[... ECMAScript code... ]]> http://www.ecma-international.org/publications/standards/Ecma-262.htm

12 ECMAScript Example <![CDATA[ var now=new Date(); hours=now.getHours(); minutes=now.getMinutes(); seconds=now.getSeconds(); ]]> The current time is hours, minutes, and <value expr ="seconds"/> seconds.

13 More on the date object The Date object stores a year, month, day, date, hour, minute, and second. Methods of the Date object include : getSeconds( ) returns the seconds in Date get Minutes( ) returns the minutes in Date getHours( ) returns the hours in Date getDay( ) returns the day of the week in Date beginning at 0 getDate( ) returns the day of the month in Date getMonth( ) returns the month in Date beginning at 0 getFullYear( ) returns the year as a 4 digit string

14 Example with : Calculating variable interest What is the amount in your account? <![CDATA[ if (amount <= 1000) {interest = 0.02} if (amount > 1000 && amount <= 10000) {interest = 0.03} if (amount > 10000) {interest = 0.04} interest_calculated = interest * amount; ]]> the interest on your balance is

15 Tutorial Exercise: ECMAScript Using the file ‘interest.vxml’ as a basis, create a file called ‘commission.vxml’ that elicits the selling price of a property and then calculates the commission fee based on the following rules: 1. if (amount <= 90000) {fee = 0.05} 2. if (amount > 90000 && amount <= 200000) {fee = 0.04} 3. if (amount > 200000) {fee = 0.03}

16 Universal Commands and Navigation

17 Overview Using a root document for global commands and storing information Navigation within and between documents The element Exercises: Using a root document Creating a subdialog

18 Root document Simple applications may consist of one document. Larger applications may consist of several documents, one of which is the root document, and the others are child documents of the root document. The root document can contain event handlers, grammars, variables, scripts and other constructs in the scope of the application which are inherited by the child documents. These elements are active throughout the entire application, unless otherwise specified. The child documents must reference the root document using the “application” attribute of the element, e.g. (assuming root document is called “root.vxml”: Note: the root document can have any arbitrary name)

19 root.vxml main menu start over Variable stored with application scope - can be referenced by leaf documents Link with grammar of words available throughout application and specification of where to go next

20 logon.vxml what is your four digit pin Assigns value to the variable ‘user_pin’ which Is stored with application scope in ‘root.vxml’

21 Retrieving the value The value stored as an application level variable can be retrieved as follows: Your pin is The prompt demonstrates that the value of ‘user-pin’ is available to each leaf document that references ‘root.vxml’

22 More on Navigation Transition to other forms etc when the FIA has processed a form (dialog) - Used within the element to select and transition to another dialog. - Used within,,,,,,,,, and - Used within,,, and Used within,,,,,,,,, and

23 Attributes for navigation Specifying the target item: next - A URI reference e.g. next="http://myexamples.com/student_system“ (absolute reference) next=“students.vxml“ (relative e.g. in same directory) next=“students.vxml #first_query" (specifies dialog within the document) nextitem - The name of an input item within the same form e.g. nextitem = “student_name” expr - A URI reference that is dynamically determined by evaluating the ECMAScript expression e.g. expr=“student_system' + '#' + ‘first_query'“ expritem - The name of an input item within the same form

24 transition to another form item within current form, another form within current document, or another document transitioning to another dialog or document using will cause the old dialog’s variables to be lost. If the variables are to persist across multiple documents, they should be stored with application scope used to submit values to the document server via an HTTP GET or POST request “namelist” attribute specifies which values are being submitted e.g. Control will not necessarily return to the calling document. For example, the script specified in the “next” attribute might generate a VoiceXML document dynamically and execution will continue with this document.

25 terminates all loaded documents and returns control to the voice browser which determines what to do next Attributes: expr—ECMAScript expression that is evaluated as the return value namelist—List of variable names to be returned example

26 Causes the voice browser to disconnect example Note: Before ending the session, developers can catch the event to perform some post- disconnect processing such as submitting any remaining data to a Web server.

27 (1) Enables the user to connect via the telephone to another voice application on another speech server. Also enables the user to connect to a person's telephone. Frequently this will be an operator or help agent that assists a user having trouble. blind transfer the caller can converse only with the party on the other end of the connection. bridge transfer the caller may converse with another party and also hear prompts and respond by speaking or pressing the keys on a touchtone telephone. This enables the caller to proactively end the transferred call.

28 (2) When the transfer is complete, the connection is broken. Once the transfer disconnects, the instructions in the element associated with the element are interpreted. The input-form-item variable may contain values including the following which indicate why the transfer was not successful: busy - The other person was busy. noanswer - The other person did not answer. network_busy - An intermediate network was not able to transfer the call. Various shadow variables contain information about a successful transfer e.g.. duration of the call transfer in seconds. mode used by the caller to terminate the transferred call (voice or DTMF

29 Enables frequently used code to be saved in a library and re-used in several applications When invoked, a subdialog executes in a new execution environment; it does not inherit any parameters from the calling dialog. The subdialog proceeds until it encounters: element—Ends the execution of a subdialog and returns control and data to the calling dialog. Data is returned to the calling dialog as a namelist. When the subdialog returns, its execution environment is deleted. element—Execution stops No form items remain eligible for the FIA to select - Execution stops

30 3. 4. 5. Welcome to the Student System Main Menu 6 7 8 9 10 11 hello 12 13 14 15 16 17 18 19 liz | margaret | mike | guest 20 21 Please say your user name. 22 23 24 25 26 1 Go to subdialog to elicit name which is returned to main dialog for greeting studentsystem3a.vxml

31 Welcome john | david | rosemary | jennifer Please say your user name </prompt hello 2 Pass value into subdialog for validation studentsystem3b.vxml

32 Welcome … elicit name … hello the student number is 3 Pass values in both directions: elicit value and pass to subdialog for validation, return to main dialog with result studentsystem3c.vxml

33 Tutorial Exercises: Using a root document 1.Assuming that you have separate documents for the main elements of the Student System - student details, course details, view student details, reports, and a main menu document - create a root document with links to these documents. Provide a link in the root document that will enable the user to navigate to the main menu document from any other document in the application. 2.Create a variable with application scope in the root document to hold the user's pin. Elicit a value for the user's pin in a file such as logon.vxml, store the value in the root document and access it from some other child document.

34 Tutorial Exercises: Subdialog (1) 3.Passing values back from a subdialog following some computation within the subdialog Load and run the file studentsystem3a.vxml. You can say one of the student names (john, david, rosemary or jennifer) in response to the system prompt. 4.Passing values into a subdialog to be referenced in that subdialog Load and run the file studentsystem3b.vxml. As before, you can say one of the student names (John, David, Rosemary, Jennifer) in response to the system prompt.

35 Tutorial Exercises: Subdialog (1) 5.Passing values in both directions Load and run the file studentsystem3c.vxml. This time you have to say the student name 'John' for the conditional statement in the subdialog to evaluate correctly. 6. Add further conditions in the subdialog for the names 'David' and 'Rosemary'. Amend the code in the main dialog so that if the user says the name 'Jennifer', the system responds 'Sorry that student is not listed in the database'. Note: Names that are not in the database will still have to be included in the recognition vocabulary to be recognised and passed on to the subdialog.


Download ppt "VoiceXML: Events, Errors, and ECMAScript. Acknowledgements Prof. Mctear, Natural Language Processing, University."

Similar presentations


Ads by Google