Student Pages
description
Transcript of Student Pages
![Page 2: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/2.jpg)
Last Time: HTML Forms and Javascript
If you haven’t finished the survey assignment, email us or come to office hours
![Page 3: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/3.jpg)
2/14: Programming Phones
![Page 4: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/4.jpg)
This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
![Page 5: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/5.jpg)
This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
Call 877-500-VXML and use my developer ID
(540460366) and pin (0123) to preview it
When you’re done, put this text into your Scratchpad and call
VXML again and use your developer ID and pin to preview
your own code
![Page 6: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/6.jpg)
Prerequisite: XML
![Page 7: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/7.jpg)
XML
Disclaimer: This is an introduction to how an XML format works in general, this is not the particular syntax of a VoiceXML program or any other specific XML format
![Page 8: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/8.jpg)
XMLOpening and closing tags
<myTellmeProgram> </myTellmeProgram>
![Page 9: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/9.jpg)
XMLNested hierarchy of tags
<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
![Page 10: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/10.jpg)
XMLNested hierarchy of tags
<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
Level 1 (Document Root)
![Page 11: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/11.jpg)
XMLNested hierarchy of tags
<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
Level 1 (Document Root)
Level 2
![Page 12: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/12.jpg)
XMLNested hierarchy of tags
<myTellmeProgram> <introduction> <welcome>Hello World</welcome> <welcome>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
Level 1 (Document Root)
Level 2
Level 3
![Page 13: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/13.jpg)
XMLTag Attributes
<myTellmeProgram> <introduction> <welcome type=“veryFirst”>Hello World</welcome> <welcome type=“casual”>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
Attribute Value
![Page 14: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/14.jpg)
XMLComments
<myTellmeProgram> <!-- this is the beginning of the introduction --> <introduction> <welcome type=“veryFirst”>Hello World</welcome> <welcome type=“casual”>Hi, What’s up?</welcome> </introduction> <mainSection> … </mainSection></myTellmeProgram>
![Page 15: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/15.jpg)
VoiceXML (Programming Phones)
![Page 16: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/16.jpg)
This script says “hello world”<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
![Page 17: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/17.jpg)
VoiceXML (Programming Phones)<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml">
</vxml>
![Page 18: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/18.jpg)
VoiceXML (Programming Phones)<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> </form></vxml>
![Page 19: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/19.jpg)
VoiceXML (Programming Phones)<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field> </field> </form></vxml>
![Page 20: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/20.jpg)
VoiceXML (Programming Phones)<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> </block> </form></vxml>
![Page 21: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/21.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
Audio (“Text to Speech”)
Exit the application
![Page 22: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/22.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
Note beginning and end tags
![Page 23: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/23.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <exit/> </block> </form></vxml>
This should be what’s in your Scratchpad now
![Page 24: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/24.jpg)
Back to Javascript
Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML
https://studio.tellme.com/vxml2/ovw/javascript.html
![Page 25: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/25.jpg)
Back to Javascript
Just like you can embed Javascript into HTML, you can embed Javascript into VoiceXML
https://studio.tellme.com/vxml2/ovw/javascript.html
But we won’t do that in this class…
![Page 26: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/26.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>
![Page 27: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/27.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>
Tag
![Page 28: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/28.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>
Tag
Attribute
![Page 29: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/29.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> </vxml>
Tag
Attribute Value: Name of another form
![Page 30: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/30.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>
![Page 31: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/31.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>
Attribute
![Page 32: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/32.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>
Attribute
Value
![Page 33: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/33.jpg)
VoiceXML: <goto> tag<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> I found my second form. <exit/> </block> </form></vxml>
Sounds like…:“Hello WorldI found my second form.”
![Page 34: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/34.jpg)
Try this in your Scratchpad<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <block> Hello World! This dialogue goes on <goto next=“#secondGreeting”/> </block> </form> <form id=“secondGreeting”> <block> and on <goto next=“#secondGreeting”/> </block> </form></vxml>
1. Guess what this script will do.2. Edit Scratchpad3. Call 1-877-500-8965
![Page 35: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/35.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field> </field> </form></vxml>
![Page 36: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/36.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>
![Page 37: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/37.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>
Attribute
![Page 38: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/38.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> </field> </form></vxml>
AttributeValue
![Page 39: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/39.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> </field> </form></vxml>
Attribute Value
![Page 40: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/40.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> </field> </form></vxml>
New “prompt” tag: child of “field”
![Page 41: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/41.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> </field> </form></vxml>
Text to Speech:“Do you like computers?”
![Page 42: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/42.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> </filled> </field> </form></vxml>
New “filled” tag: child of “field”
![Page 43: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/43.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.
</filled> </field> </form></vxml>
Text to Speech:“Great, I got
your answer”
![Page 44: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/44.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.
</filled> </field> </form></vxml>
Broken!
![Page 45: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/45.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I heard your answer.
</filled> </field> </form></vxml>
Broken!
![Page 46: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/46.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers” type=“boolean”> <prompt> Do you like computers? </prompt> <filled> Great, I got your answer.
</filled> </field> </form></vxml>
Broken!
![Page 47: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/47.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt>
<filled> Great, I got your answer. </filled> </field> </form></vxml>
Since the predefined boolean grammar isn’t working, we’ll add one ourselves
![Page 48: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/48.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
Press 1 or 2, record the
answer
Copy and paste this to receive any “1 or
2” input
![Page 49: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/49.jpg)
VoiceXML: Form Blocks<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
![Page 50: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/50.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Input type will be a touch tone keyboard
![Page 51: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/51.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Reference some touch tone input gathering code
![Page 52: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/52.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
A grammar can have many rulesIn this example, when this
grammar is used, it should start with the rule named “top”
![Page 53: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/53.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
“one-of” tag: user specifies one of the
following items
![Page 54: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/54.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
The allowable items are “1” and “2”
![Page 55: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/55.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Text to Speech:“Great, I got
your answer”
![Page 56: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/56.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Try this!
![Page 57: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/57.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Now let’s do something with the input after it’s identified
![Page 58: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/58.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. </filled> </field> </form></vxml>
VoiceXML: Form Blocks
![Page 59: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/59.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
![Page 60: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/60.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
“if-else” tag:Special two-part tag:
1. The if part2. The else part
![Page 61: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/61.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
If some condition is met, do what follows here
Otherwise, do what follows here
![Page 62: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/62.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
The “if” tag has a “cond” condition
attribute
The condition here is that the “likeComputers” field is filled with the value “1”
![Page 63: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/63.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
Notice the double “==“
![Page 64: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/64.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
If the condition is true, say this.
![Page 65: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/65.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
If the condition is not true, say this
![Page 66: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/66.jpg)
<vxml version="2.1” xmlns="http://www.w3.org/2001/vxml"> <form> <field name=“likeComputers”> <prompt> Do you like computers? </prompt> <grammar mode="dtmf" root="top” version="1.0" tag-format="semantics/1.0" type="application/srgs+xml"> <rule id="top"> <one-of> <item>1</item> <item>2</item> </one-of> </rule> </grammar> <filled> Great, I got your answer. <if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if> <exit/> </filled> </field> </form></vxml>
VoiceXML: Form Blocks
[If time in class]: Try it! (might want to download the
slides and copy and paste from them, but you’ll have to fix up the quotes)
![Page 67: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/67.jpg)
VoiceXML HomeworkIn this homework you have two options (extra credit: do both!):1. Use the prompt/grammar/filled children of the field tag to ask a question.
Modify what we’ve done to accept more than “1” and “2” as input, and have the computer say something different in response to each one
2. Use the prompt/grammar/filled children of the field tag to ask a question. Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.
Add a tiny bit of text to your webpage with your Developer ID & pin so that we can listen. Also send Ken ([email protected]) and me ([email protected]) an email with the contents of your Scratchpad.
Due Tuesday, February 22nd before sunrise.
![Page 68: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/68.jpg)
Hint for Option #11. Use the prompt/grammar/filled children of the field tag to ask a question.
Modify what we’ve done to accept more than “1” and “2” as input, and have the computer say something different in response to each one
<if cond="likeComputers==1"> I'm glad you like computers. <else /> Too bad that you don't like computers. </if>
<if cond="likeComputers==1"> I'm glad you like computers.</if><if cond="likeComputers==2"> Too bad that you don't like computers.</if>
=
![Page 69: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/69.jpg)
Hint for Option #22. Use the prompt/grammar/filled children of the field tag to ask a question.
Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.
<if cond="likeComputers==1"> I hope you’ll like computers forever <else /> Too bad that you don't like computers. </if>
<form id=“secondGreeting”> <block> and ever <goto next=“#secondGreeting”/> </block> </form>
+<goto next=“#secondGreeting”/>
+
![Page 70: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/70.jpg)
Another Hint for Option #22. Use the prompt/grammar/filled children of the field tag to ask a question.
Then, if the user inputs a “1”, have the computer repeat a phrase forever. If the user inputs a “2”, just have the computer say one thing.
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"> <form>…</form>
<form id=“second”>…</form></vxml>
Note that your single <vxml> code can
include multiple forms
![Page 71: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/71.jpg)
More Advanced Phone Programming
![Page 72: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/72.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 73: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/73.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 74: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/74.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 75: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/75.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 76: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/76.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 77: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/77.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 78: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/78.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
![Page 79: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/79.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
Major Components:1. Block introduction2. Field for user input3. Grammar4. Prompt5. Filled(6. catch)
![Page 80: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/80.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
Grammar:Speech Recognition, not Touch Tone like before
![Page 81: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/81.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
Grammar:Three possible answers:
Apple, Orange, Pear
![Page 82: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/82.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
Grammar:For Apple can say “apple” or “red”
![Page 83: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/83.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
Filled:Repeats the input that is heard
![Page 84: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/84.jpg)
<?xml version="1.0"?><vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"><form id="pick_fruit"> <block> Welcome to the fruit picker. </block><field name="fruit"> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item><one-of> <item>apple</item> <item>red</item> </one-of><tag>out.fruit = "apple";</tag> </item> <item><one-of> <item>orange</item> </one-of><tag>out.fruit = "orange";</tag> </item> <item><one-of> <item>pear</item> </one-of><tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <prompt>Pick a fruit.<break size="medium"/></prompt> <catch event="noinput nomatch"> Please pick a fruit. </catch> <filled> You picked <value expr="fruit"/> <!-- clear the form item variable to pick another --> <clear namelist="fruit"/> </filled></field></form></vxml>
No match with Grammar or No input at all:“Please pick a fruit”
![Page 85: Student Pages](https://reader036.fdocuments.us/reader036/viewer/2022081502/56816376550346895dd454cb/html5/thumbnails/85.jpg)
More Advanced Phone Programming:
Full example with even more bells and whistles here:
https://studio.tellme.com/vxml2/ref/elements/prompt.html