| CallXML 3.0 Development Guide | Home | Frameset Home |
|
<on> event handler <on> element, which eclipses the older <on(eventName)> handler elements, and offers a much more flexible, and powerful option for event and error handling.
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
</callxml>
<do> container element to hold our content, and we will introduce our 'choice' element with some numeric values defined:
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<do choices="1,2,3">
<say>
welcome to the virtual shopping mall.
you may press the floor you wish to visit by pressing the number on your telephone keypad.
</say>
<say>
you can press one, two or three.
</say>
<wait value="5s"/>
</do>
</callxml>
<do choices ="11, 12, 13"> are not doable in this manner. Thus, a caller can press "1", "2", or "3", and the system will recognize it. While we now have an inkling as to how to set up a list of available inputs for our callers, we still need to trap the event itself, and respond appropriately, right? Let's take a look at how the new <on> event handling element fits the bill:<on> element to filter our caller's input actions, and handle them as we see fit. For those of us used to seeing the <ontermdigit> handler from CallXML 2.0, the new <on> element will seem pretty familiar. Those of us that are super-familiar with CallXML2.0 will doubtlessly see why this new element offers a much better method and syntax of handling our application events than the now-deprecated <ontermdigit/onerror/onexternalevent/etc> elements. For those of you who aren't familiar with Jack, let's take an in-depth look at handling our recognition events:<on event="choice:(choice name)"<on> element has a required 'event' attribute which defines what occurance we want to trap and handle. The 'choice:' prefix in the value defines the specific voice input or dtmf choice that we will execute this handler on. From this explanation, it seems that including some handlers for the events of '1,2,3' would be pretty intuitive for us:
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<do choices="1,2,3">
<say>
welcome to the virtual shopping mall.
you may press the floor you wish to visit by pressing the number on your telephone keypad.
</say>
<say>
you can press one, two or three.
</say>
<wait value="5s"/>
<on event="choice:1">
<say> going up. first floor.</say>
</on>
<on event="choice:2">
<say> going up. second floor.</say>
</on>
<on event="choice:3">
<say> going up. third floor.</say>
</on>
</do>
</callxml>
<on> handlers so that they are looking for a voice command, and not a keypress:
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<do choices="housewares, bed and bath, sporting goods">
<say>
welcome to the virtual shopping mall.
you may say the department store you wish to visit in order to start the elevator.
</say>
<say>
you may choose housewares, bed and bath, or sporting goods.
</say>
<wait value="5s"/>
<on event="choice:housewares">
<say> now arriving at first floor, housewares.</say>
</on>
<on event="choice:bed and bath">
<say> now arriving at second floor, bed and bath. </say>
</on>
<on event="choice:sporting goods">
<say> now arriving at third floor, sporting goods. </say>
</on>
</do>
</callxml>
<on> element. Hey, not so fast there, pal. Performing surgery without studying the course material is like...performing liver surgery. With a Chilton's guide for a '78 Buick as our only reference. Brrrr........
<do choices="ReturnValue1 (user utterance one A, user utterance one B, 1),
ReturnValue2 (user utterance two A, user utterance two B, 2),
ReturnValue3 (user utterance three A, user utterance three B, 3)">
<on event="choice:"> element), upon a recognized user utterance. We define our valid voice commands ("user utterance one A", and the like), immediately after the 'return value' declaration, in a comma-delimited list contained with parenthesese. We can define any number of valid user utterances, or return values within our 'choice' attribute, as long as we got our syntax right, (watch those commas, Ladies and Gents!). Now that we have wrapped our collective heads around these concepts, let's put engage in making the Word into Flesh:
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<do choices="1st Floor (first, housewares, 1),
2nd Floor (second, bed and bath, 2),
3rd Floor (third, sporting goods, 3)">
<say>
welcome to the virtual shopping mall.
you may say the department store you wish to visit to start the elevator,
or you may simply press the floor number on your telephone keypad.
</say>
<say>
you may choose housewares on the first floor,
bed and bath on the second floor,
or sporting goods on the third floor.
</say>
<wait value="5s"/>
<on event="choice:1st Floor">
<say> now arriving at $session.lastchoice; </say>
</on>
<on event="choice:2nd Floor">
<say> now arriving at $session.lastchoice;</say>
</on>
<on event="choice:3rd Floor">
<say> now arriving at $session.lastchoice;</say>
</on>
</do>
</callxml>
| ANNOTATIONS: EXISTING POSTS |
| login |
|