1 / 25

VXML: return and submit

VXML: return and submit. Speaker: Yan-Shiang Wang Date:2006.5.18. <return> element. The return element is used to terminate a subdialog and return control to the main dialog. The event and namelist attributes are mutually exclusive.

geri
Download Presentation

VXML: return and submit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VXML: return and submit Speaker: Yan-Shiang Wang Date:2006.5.18

  2. <return> element • The return element is used to terminate a subdialog and return control to the main dialog. • The event and namelist attributes are mutually exclusive. • The message and messageexpr attributes are mutually exclusive. • Parents • block, catch, error, filled, foreach, help, if, noinput, nomatch, prompt • Children • none

  3. Demo1 - return (return.vxml) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <form id="Demo1"> <subdialog name="SubD_1" src="MySubD.vxml"> <param name="confirm_prompt" expr="'Do you think Brokeback Mountain is a good movie?'"/> <filled> <if cond="SubD_1.response=='yes'"> <prompt>You are probably right.</prompt> <elseif cond="SubD_1.response=='no'"/> <prompt>You are probably wrong.</prompt> </if> </filled> </subdialog> </form> </vxml> Note:SubDialogName.FieldName

  4. MySubD.vxml(1/2) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <form id="Demo1"> <var name="confirm_prompt"/> <var name="response"/> <field name="field_confirm" type="boolean"> <prompt> <value expr="confirm_prompt"/> </prompt>

  5. MySubD.vxml(2/2) <filled> <if cond="field_confirm == true"> <assign name="response" expr="'yes'"/> <else/> <assign name="response" expr="'no'"/> </if> <prompt>You say <value expr="response"/>.</prompt> <return namelist="response"/> </filled> </field> </form> </vxml>

  6. <return> syntax & attributes <return event = "string" eventexpr = "ECMAScript_Expression" message = "string" messageexpr = "ECMAScript_Expression" namelist = "var-1 var-2 ... var-n" /> • event - event to throw to the subdialog • namelist - variables to return • eventexpr - event to throw (ECMAScript) • message - additional information about the event being thrown • messageexpr - additional information (ECMAScript)

  7. Demo2 - return event (return1.vxml) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <catch event="MyEvent"> <prompt>Of course. This is a demo for return event.</prompt> </catch> <form id="Demo2"> <subdialog name="SubD_1" src="MySubD_1.vxml"> <param name="confirm_prompt" expr="'This is a demo for return event, right?'"/> <filled> <prompt>I thought so.</prompt> </filled> </subdialog> </form> </vxml>

  8. MySubD_1.vxml(1/2) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <form id="Demo2"> <var name="confirm_prompt"/> <var name="response"/> <field name="field_confirm" type="boolean"> <prompt> <value expr="confirm_prompt"/> </prompt>

  9. MySubD_1.vxml(2/2) <filled> <if cond="field_confirm == true"> <assign name="response" expr="'yes'"/> <else/> <assign name="response" expr="'no'"/> </if> <prompt>You say <value expr="response"/>.</prompt> <return event="MyEvent"/> </filled> </field> </form> </vxml>

  10. Demo3 - return namelist (return2.vxml) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <form id="Demo3"> <subdialog name="SubD_1" src="MySubD_2.vxml"> <param name="confirm_prompt" expr="'Do you think Brokeback Mountain is a good movie?'"/> <filled> <prompt>Your opinion about Brokeback Mountain is</prompt> <if cond="SubD_1.response1=='yes'"> <value expr="SubD_1.response2"/> <elseif cond="SubD_1.response1=='no'"/> <value expr="SubD_1.response2"/> </if> </filled> </subdialog> </form> </vxml>

  11. MySubD_2.vxml(1/2) <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1"> <form id="Demo3"> <var name="confirm_prompt"/> <var name="response1"/> <var name="response2"/> <field name="field_confirm" type="boolean"> <prompt> <value expr="confirm_prompt"/> </prompt>

  12. MySubD_2.vxml(2/2) <filled> <if cond="field_confirm == true"> <assign name="response1" expr="'yes'"/> <assign name="response2" expr="'probably right.'"/> <else/> <assign name="response1" expr="'no'"/> <assign name="response2" expr="'probably wrong.'"/> </if> <prompt>You say <value expr="response1"/>.</prompt> <return namelist="response1 response2"/> </filled> </field> </form> </vxml> Note:namelist="var1 var2 var3 …"

  13. <submit> element • The use of the submit tag will transition control to a new document, either via the GET or POST methods. • Dissimilar to the goto element, submit allows the developer to submit a space-delimited list of variables to the destination document. • Parents • block, catch, error, filled, foreach, help, if, noinput, nomatch, prompt • Children • none

  14. <submit> syntax <submit enctype = "encoding_type" expr = "ECMAScript_Expression" fetchaudio = "URI" fetchaudioexpr = "ECMAScript_Expression" fetchhint = "string" fetchtimeout = "string" maxage = "seconds" maxstale = "seconds" method = "string" namelist = "string" next = "URI" />

  15. <submit> attributes • namelist - variables to submit • next - target to submit (URI) • enctype - MIME encoding type of the submitted data • application/x-www-form-urlencoded (default) • multipart/form-data (binary data) • expr - target to submit (ECMAScript) • fetchaudio - audio to play while fetching resource (URI) • fetchaudioexpr - audio to play (ECMAScript)

  16. <submit> attributes (cont.) • fetchhint - resource be fetched during application execution • prefetch - begin the resource fetch upon initial document execution • safe - resource may only be fetched when needed (default) • fetchtimeout - timeout seconds or milliseconds (default is 15s) • method - GET (default) or POST • strongly advised not to rely on this attributebest controlled by the hosting server's response headers • maxage - maximum acceptable age in sec (Cache-Control) • maxstale - maximum acceptable staleness in sec (Cache-Control)

  17. Demo4 - submit_city (submit_city.vxml) <?xml version="1.0"?> <vxml version="2.1"> <form> <field name="city"> <prompt>What city do you want to visit, just choice it. Taipei press 1 Taichung press 2 Nantou press 3 Kaohsiung press 4 <option value="Taipei" dtmf="1">Taipei</option> <option value="Taichung" dtmf="2">Taichung</option> <option value="Nantou" dtmf="3">Nantou</option> <option value="Kaohsiung" dtmf="4">Kaohsiung</option> <filled> <submit next="city_intro.php" namelist="city"/> </filled> </field> </form> </vxml>

  18. city_intro.php(1/2) <?php $user_get=$_REQUEST['city']; if ($user_get=="Taipei") $city_status="This is modern city."; else if ($user_get=="Taichung") $city_status="This is my hometown."; else if ($user_get=="Nantou") $city_status="I study here, now."; else $city_status="I have been there for 4 years."; $h = date("H"); $m = date(“i"); $s = date(“s"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?> Note:$_REQUEST['VaribleName']

  19. city_intro.php(2/2) <vxml version="2.1"> <form> <block> <prompt> <prosody rate="-20%"> You choice <?=$user_get?>. <?=$city_status?> </prosody> <prosody rate="-40%"> Now is <?=$h?>clock <?=$m?> and <?=$s?>second. </prosody> </prompt> </block> </form> </vxml>

  20. Demo5 - submit_record(1/2) (submit_record.vxml) <?xml version="1.0"?> <vxml version="2.1"> <form id="record_greeting"> <record name="personal_greeting" dtmfterm="true" beep="true"> <prompt> At the tone, please record your personal greeting. When you're done, press pound. </prompt> </record>

  21. Demo5 - submit_record(2/2) <field name="conf"> <prompt> Here's what callers will hear. <break size="small"/> <audio expr="personal_greeting"/> </prompt> </field> <block> <submit next="mail_record.php" namelist="personal_greeting" method="post"/> </block> </form> </vxml>

  22. mail_record.php(1/2) <?php $tmpFile=$HTTP_POST_FILES['personal_greeting']['tmp_name']; if (is_uploaded_file($tmpFile)) { $file_name = date("mdHi"); $wavfile="wav/" . $file_name . ".wav"; copy($tmpFile, sprintf("%s",$wavfile)); $msg = "audio saved"; include("basic_att_mail.php"); } else { $msg = "unable to save audio"; } ?> Note:mail the wav file via PHP script

  23. mail_record.php(2/2) <vxml version="2.1"> <form> <var name="msg" expr="'<?=$msg?>'"/> <var name="file" expr="'<?=$file_name?>'"/> <block> <break size="medium"/> <value expr="msg"/> <break size="medium"/> <audio expr="'wav/' + file + '.wav'">your greeting</audio> </block> </form> </vxml>

  24. Review • what we learn today • return • submit • dependence • subdialog • param • catch • record • audio

  25. Reference • TellMe • https://studio.tellme.com/ • VoiceXML Development Guide • http://www.vxml.org/ • 究極PHP • 學貫出版 • Source Code • http://stu.csie.ncnu.edu.tw/~94321517/vxml_sourcecode.rar

More Related