| VoiceXML 2.1 Development Guide | Home | Frameset Home |
| charset | Data Type: CDATA | Default: Optional |
| The charset attribute defines the character encoding of the script contained within the element. | ||
| fetchhint | Data Type: (prefetch|safe) | Default: safe |
Fetchhint is used to specify when the resource should be fetched during application execution. The possible values and their descriptions are:
Note that the Voxeo platform will always *not* prefetch content by default. As such, a developer should specify a value of ''prefetch" if resources are to be made available prior to execution of application content. | ||
| fetchtimeout | Data Type: CDATA | Default: 5s |
| The fetchtimeout attribute allows the developer to specify how much time to allow on a fetch before throwing an error.badfetch event. This can be specified globally by using the fetchtimeout property in the application root document. If not specified, it will default to 5 seconds. Also note the strict formatting of this value; if specified, the time value must have the ‘s’ denomination appended to it, else an error.badfetch is thrown: <script src="MyScript.js” fetchtimeout=”5s”/> | ||
| maxage | Data Type: CDATA | Default: Optional |
| The maxage and maxstale attributes replace the VXML 1.0 caching attribute for compliance to the w3c vxml 2.0 specification. The value for this attribute specifies the maximum acceptable age, in seconds, of the resource in question. However, it is strongly advised not to rely on this attribute for cache-control; caching is always best controlled by the hosting server's response headers. If no headers are specified, then no cache control will be present, regardless of the value set for the maxage and maxstale attributes. | ||
| maxstale | Data Type: CDATA | Default: Optional |
| The maxage and maxstale attributes replace the VXML 1.0 caching attribute for compliance to the w3c vxml 2.0 specification. The value for this attribute specifies the maximum acceptable staleness, in seconds, of the resource in question. However, it is strongly advised not to rely on this attribute for cache-control; caching is always best controlled by the hosting server's response headers. If no headers are specified, then no cache control will be present, regardless of the value set for the maxage and maxstale attributes. | ||
| src | Data Type: string - URI | Default: Optional |
| The src attribute specifies the URI where the external script content is located. Note that either inline script content or an external src may be referenced, but not both. | ||
| srcexpr | Data Type: CDATA | Default: Optional |
| The srcexpr attribute evaluates to an ECMAScript value that defines the target URI. Either srcexpr or src may be specified for the element, but not both. | ||
| function ruleFunction() {
return ("here is a nifty little sample script"); } |
| <?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1"> <meta name="author" content="Matthew Henry"/> <meta name="copyright" content="2005 voxeo corporation"/> <meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/> <form id="F1"> <block> <script src="MyScript.js" maxage="5000" maxstale="5000"/> <prompt><value expr="ruleFunction()"/> </prompt> </block> </form> </vxml> |
| <?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1"> <meta name="author" content="Matthew Henry"/> <meta name="copyright" content="2005 voxeo corporation"/> <meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/> <form id="F1"> <block> <script src="MyScript.js" fetchhint="prefetch" fetchtimeout="10s"/> <prompt><value expr="ruleFunction()"/> </prompt> </block> </form> </vxml> |
| ANNOTATIONS: EXISTING POSTS |
Lampei
|
|
| Is there a way to reference a script in another part of the same document, thus being able to reuse the same functions? e.g. If I put my script in the application file of my vxml project, can I then reference it something like application.form_name.block_name.my_function_here() ? | |
Lampei
|
|
| Also, w3.org has the script element available in both vxml and form elements. Is this the same at Voxeo? (I only ask as they're not included in this "parent" list) http://www.w3.org/TR/voicexml20/#dml5.3.12 Thanks. | |
MattHenry
|
|
| Hi again,
I don't think that referencing a script like this is going to fly. If it was my own code, I would put all the client-side stuff in a seperate file, (myScript.js), and refernce it via the <script src> element/attribute. This not only does the job, but keeps the JS segregated from the XML, making a much cleaner bit of code to view and edit. And yes, I did forget to include the form and vxml elements as valid parent elements, which has been corrected. Thanks again for catching my goof. ~Matt |
|
Asier
|
|
| Hello there,
I need build this structure: reg reg1 ok pin reg2 (should be a dynamic array) cc saldo and i dont know how do it, please help me to do it with any sample code, in ECMAScript. Thanks in advance, Asier |
|
Asier
|
|
| Sorry, this is possible like that:
function registro(ok, pin, numidem, nombre, idioma, sexo) { this.reg1 = new registro1(ok, pin, numidem, nombre, idioma, sexo) this.reg2 = new Array; } function registro1(ok, pin, numidem, nombre, idioma, sexo) { this.ok = ok this.pin = pin this.numidem = numidem this.nombre = nombre this.idioma = idioma this.sexo = sexo } function registro2(cc, saldo) { this.cc = cc this.saldo = saldo } var reg = new registro("ok", "pin", "numidem", "nombre", "idioma", "sexo" ) ; var regis2 = new registro2("cuenta corriente", "saldo"); var prueba = "pepe"; var n = 5; for(i=0;i<n;i++) { var x = i; var x = new registro2("cuenta corriente", "saldo"); reg.reg2.push(x); reg.reg2[i].cc = "cuenta corriente " + i; } |
|
MattHenry
|
|
|
Hello Asier, Glad you got it worked out. ~Matt |
|
jesusla
|
|
| Hi,
Do you have a list of all voxeo-specific global functions available within Javascript? In particular, I'd like to know if there's a function to log to the voice browser log (akin to the "log" vxml element). Thank you, -Jesus |
|
VoxeoTony
|
|
| Hello Jesus,
We do not have Voxeo-specific global functions available for Javascript. We do support the log element based on the W3C spec, not a Voxeo-specific spec element. http://docs.voxeo.com/voicexml/2.0/log.htm I hope this answer helps, please let us know if you need anything else. Regards, Tony |
|
mho
|
|
| Note on external files (in case anyone else runs into this)
The system gets confused when you use things like %lt; and %gt; instead of < and > when you are using javascripts in extrnal files. |
|
fliptone
|
|
| A client wants to enter an amount like DDDCC, where $154.12 would be entered as 15412. Of course they want it read back like a proper amount! I wrote a JavaScript function that builds an amount string from the digits, but I can't seem to figure out how to pass the field value to my function. I tried this:
<var name="formattedResponse" expr="formatResponse( response )" /> and <assign name="formattedResponse" expr="formatResponse( response )" /> among other things but always seem to get back "$NAN". Help! PS: They also want to enter dates MMDDYY so I have the same problem there as well! |
|
MattHenry
|
|
|
Hey folks, I suspect that this is due to the fact that we are declaring the value as a string, instead of a number, and then trying to perform mathematical operations on it: STRING: <var name="myVar" expr="'1234'"/> NUMBER: <var name="myVar" expr="Number(1234);"/> Give this a try, and see if you have better luck. ~Matt |
|
fliptone
|
|
| Matt,
thanks for your help. (again!) turns out I had my <assign> tag as the child of a <field> and so my JS function wasn't even running. Oddly, I wasn't getting a "bad document" error. Thanks again. |
|
MattHenry
|
|
|
Hi there, Bear in mind that as I don't have the full code that you are working with, I can only make guesses as to why this isn't working as intended. If you'd like to create a simplified test case, and attach it to this thread along with a thorough description of what isn't working for you, we might be able to offer you some accurate suggestions on how to fix the problem. Regards, ~Matthew Henry |
|
crishvi
|
|
| hello!!i don't know where to post this so i'm posting it here, sorry if its not the right thread...i wanted to ask if there is any method to concatenate in vxml or even using script ??? I'm doing an application where the user should enter the password which is in characters...since it gets complicated through dtmf mode I'm planning to take the input from the user alphabet by alphabet and concatenate all those into a string through some loop function and get the password and read it out to the user. Please reply as soon as possible if there is some way out. thanks in advance. | |
mikethompson
|
|
| Hello,
You can actually do string concatenation within the grammars themselves. I'm not sure which style of grammar you're using (SRGS or GSL), but you should definitely check out the subgrammar sections for both languages: http://docs.voxeo.com/voicexml/2.0/mot_appendixj.htm http://docs.voxeo.com/voicexml/2.0/mot_appendixi.htm In short, here's how you would string concat in GSL: top level rulename MYRULE [ NAME:d {<MyName $d>} ] ; sub-rule NAME ( ; assign results from 'FIRSTNAME' to slot 'a' FIRSTNAME:a ; assign results from 'MIDDLENAME' to slot 'b' MIDDLENAME:b ; assign results from 'LASTNAME' to slot 'c' LASTNAME:c ) ; concatenate results from slots a, b, and c and return {return(strcat($a strcat($b $c)))} FIRSTNAME [ [matthew] {return("matthew ")} ] MIDDLENAME [ [warren] {return("warren ")} ] LASTNAME [ [henry] {return("henry ")} ] Hope this helps, Mike Thompson Voxeo Corporation |
|
jefo12
|
|
| To request an appointment this week you can say today, tomorrow ,day after tomorrow or a specific day such as this Friday.you can also request the day next week such as next Friday.plz make ur request now Such as today,tomorrow,day after tomorrow,this Friday or next Friday. For a specific date, say date.
if the user says tuesday i hav to get the date as tuesday march 2nd like that i hav to write the script canu plz suggest.... |
|
VoxeoDustin
|
|
| Hey Jefo,
That kind of script will require a bit of server side logic, as VXML does not inherently have that ability. I've included some links below on PHP that should get you pointed in the right direction on determining date with a little server side logic. http://us.php.net/date http://php.net/ Thanks, Dustin |
|
jefo12
|
|
| <?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1"> <script> var myarr = new Array(); function ParseAppointments(str) { if(str.length==0) return null; else myarr=str.split("$"); return myarr; } function giveLength(myarr) { return myarr.length; } </script> <form id="greeting"> <block> <if cond="myarr=='null'"> <prompt> hai how are you </prompt> <else/> <prompt>welcome back you have <value expr="giveLength(parseAppointments("10-08-2008$10:30"))"/> appointments </prompt> <prompt> The appointments are </prompt> <foreach item="applist" array="myarr"> <prompt><value expr="applist"/><break/></prompt> </foreach> </block> </form> </vxml> this code is not working can you plz help me out to ..... what i'm having is i collect the appointments from the database in the form of strings and i pass it to a javascript and stores in an array..split the string and finally plays back all the appointments.... |
|
voxeojohnq
|
|
| Jefo:
After briefly looking through your code, I noticed a few things that jumped out at me. 1) You should wrap everything inside of the <script> tags with <![[CDATA ]]> tags. Although, this is not required for your sample code, i consider it part of best-coding practices. 2) <if cond="myarr=='null'"> this condition will never evaluate to true as myarr is an array or returned as null from your parseAppointments function. 3) You have " inside of the expr attribute in the <value> tag. To clarify: <value expr="giveLength(parseAppointments("10-08-2008$10:30"))"/> is invalid because the value of expr containes "". Try replacing the quotes with '' 4) This statement giveLength(parseAppointments("10-08-2008$10:30")) has a possibility of failing as the parseAppointments function will return null which is an invalid argument to giveLength. Generally speaking, it is a good idea to open your XML document in FireFox or IE to check for parse errors. Regards, John Quinn Voxeo Support |
|
learnvxml
|
|
| Hello!
Can you help me with these 2 JavaScript questions. 1. substring: var bill_due_date = "20101231"; var y,m,d; y = bill_due_date.substring(0, 4); m = bill_due_date.substring(4, 6); d = bill_due_date.substring(6, 9); bill_due_date = m + "/" + d + "/" + y; When I test this interactively in JavaScript (in w3schools), it works. In Voxeo platform, this code has yielded the error: String index out of range: 9 2. DOM: While dom.documentElement.getElementsByTagName("bill_due_date").item(0).firstChild.data works, dom.getElementById("bill_due_date").firstChild.data does NOT work! Error says firstChild cannot operate on null value. This has worked in other platforms. I see NO documentation on which DOM methods are supported in Voxeo's Javascript! Are all DOM objects, methods and properties supported? Appreciate it! Santhana. |
|
voxeoJeffK
|
|
| Hello Santhana,
Concerning your substring inquiry, I am able to run that successfully: <log expr="'*********** ' + bill_due_date"/> gives me LOG: *********** 12/31/2010 If you'd like to attach a sample script and logging from the Application Debugger we can certainly look into your results. Concerning the DOM, no not all of the DOM is supported. Prophecy uses the Rhino JS interpreter, and you will want to use getElementsByTagName for DOM access. It may be of note that for retrieving data using the <data> element (which is the most common reason to use DOM) it does support E4X, which is more powerful over the older DOM functions in that the XML data becomes a Javascript object. You would declare the data with the additional e4x attribute: <data name="xmlDataIn" src="myXmlSourceData.xml" ecmaxmltype="e4x"/> <assign name="myData" expr="xmlDataIn"/> So for an XML structure of: <snack> <bag> <candy id="mine"> <piece>Reese's</piece> </candy> </bag> </snack> you would easily access pieces like so: myData.bag.candy.piece and the value of an ID is easily gotten as object.node.(@attribute): bag.candy.(@id) and a comparison would be: bag.candy.(@id == "mine") Regards, Jeff Kustermann Voxeo Support |
|
runebjerke
|
|
| I wanted to call a web script without requesting a new VoiceXML document (i.e. not "submit" or "goto"), so I tried this:
<block> <assign name="foo" expr="'http://example.org/some-script.php?' + Math.random() + '&' + session.callerid" /> <script srcexpr="foo" maxage="1" maxstale="1" /> </block> (Obviously I'm submitting more interesting values than Math.random() in reality..) The script just returns an empty document. This SEEMS to work quite well, but is it a "sane" way of doing something like this? Is there a better alternative? (No async http requests?) |
|
VoxeoBrian
|
|
| Hello,
For fire and forget fetches, you should use the <data> element, we have documentation on that here: http://www.vxml.org/data.htm Regards, Brian F. |
|
ermal
|
|
| Hi
I have an application in asp.net in booth side (server and client) I'm trying to build an javascript to operate like a client to send a command to server. In asp.net client command is like this: command = "<Selection device=\"room\" address=\"127.0.0.1\" command=\"-2\" />"; Could anyone help me how can i make an command in java script and than to use this script in vxml. Thanks in advance, Ermal |
|
voxeoJeffK
|
|
| Hello,
In VoiceXML you can achieve this using the <data> element, and include the command in the "namelist": http://www.vxml.org/data.htm Regards, Jeff Kustermann Voxeo Support |
|
ermal
|
|
| Thanks voxeoJeffK
Can you please give me an example how can i Use <data> and "namelist" for this command? |
|
VoxeoDante
|
|
| Hello,
Would you be able to trigger the command via HTTP POST or GET? If so, that is going to be the easiest way to do this. The <data> would be perfect for this, and assuming that it would accept Command and Device as Parameters, you could create those as variables in the VXML application and send them off to the application in the request. <data name="MyData" src="MyData.asp" namelist="command device"/> Outside of that, you would likely have to create some proxy service that would accept the POST from VXML and convert it into the Visual Studio command. I hope this helps. Regards, Dante Vitulano Hosted Solutions Engineer Download Prophecy 10 (link: http://voxeo.com/prophecy ) | Prophecy 10 Docs (link: http://docs.voxeo.com/prophecy/10.0/home.htm ) |
|
ermal
|
|
| I'm trying to make an IVR menu.
When I pres 1 from dtmf i need to have conected to a web link. (Just tu send a request) Can any help me witch is the best way to do that? |
|
kazokanishi
|
|
| Hi ermal,
Your question may not be suitable for this forum. I went ahead created a ticket in your account for you. So we can discuss in details. Best regards, Kaz O. Voxeo Support |
|
ermal
|
|
| Hi
can anybody help me with some javascript to provide web button click on vxml call. |
|
voxeoJeffK
|
|
| Hello,
We have a tutorial on using a web form to initiate a VoiceXML application located here: http://www.vxml.org/t_15.htm Let us know if we can help further. Regards, Jeff Kustermann Voxeo Corporation |
|
dcooper
|
|
| Hi,
I need to determine today's date in my script. I have created a test script as below. <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1" > <block> <var name="iCurrentMonth" /> <script> var d = new Date(); iCurrentMonth = d.getUTCMonth()); </script> <!-- The current month is... --> <log expr="'***** month's value is: ' + iCurrentMonth"/> </block> </vxml> When I run this, it gives me compilation error saying that Date() is not recognized. How do I go about using javascript in my vxml script? Thanks for your help in advance. |
|
VoxeoDante
|
|
| Hello,
I think you can do this in a much more simple way. Give this a try; [code] <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1" > <var name="myDate" expr="new Date()"/> <var name="CurrentMonth" expr="myDate.getMonth()"/> <form> <block> <log expr="'Current Month Is ' + CurrentMonth"/> </block> </form> </vxml> [/code] I hope this helps. Regards, Danté Vitulano Solutions Architect [url=http://www.voxeo.com/university/home.jsp] [img=http://www.voxeo.com/images/logos/VoxeoUnivLogo.png/] [/url] [b][color=blue]Interested in Training? Visit the Voxeo University Page to Learn More![/color][/b] |
|
rubinikuttyomkumar
|
|
| HI
Can i get any help regarding posting a XML packet over HTTP. Is there any support to post XML or only query string is allowed ? |
|
voxeoshanesmith
|
|
| Hi,
I'm guessing that you are talking about implementing a RESTful type interface. Since VXML doesn't natively support this (though you could contrive something via the data tag and javascript magic) it's best to accomplish any RESTful calls you need to make via your server-side language instead. Keep in mind as well that it's not only the getting of the XML data to an API, but also formatting and handling any response that makes me want to use server-side code instead of VXML to accomplish. Since in most applications you're dynamically generating the VXML output via Java, C#, PHP, etc... it's just more intuitive to implement backend data calls from the server-side, keeping VXML in use just as the presentation layer. Hope that helps, please let me know if we can be of any further assistance. Regards, Shane |
| login |