| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
<meta name="maintainer" content="YOUREMAILADDRESS@HERE.com"/>
<form id="Hello World">
<block>
<prompt>
Hello there. The caller i d number is <value expr="session.callerid"/>
The called i d of this application is <value expr="session.calledid"/>
<prompt>
</block>
</form>
</vxml>
<say-as> elements so that our phone number was spoken as a set of digits, but just to illustrate how JavaScript works in your VoiceXML application, we will tackle this problem from another direction. <script> element to write a JavaScript function. This function will add the spaces so that we can hear our phone number the way it should be, instead of "eight billion...". <script> element allows you to include scripting language code in your application. In this case, the scripting language is JavaScript. Code contained in the <script> element is executed on the client side, so we don't have to go to the back-end server for such a simple task. Each <script> element follows the same scoping rules as other elements, meaning, the <script> element is executed in the scope of the containing element.
<script>
<![CDATA[
function sayasDigits(number)
{
var digitNumber = number.charAt(0);
for(var i = 1; i < number.length; i++)
{
digitNumber += ' ' + number.charAt(i);
}
return digitNumber;
}
]]>
</script>
<prompt>
Hello there. The caller i d number is:
<value expr="sayasDigits(session.callerid)"/>
</prompt>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="maintainer" content="YOUREMAILADDRESS@HERE.com"/>
<form id="HelloWorld">
<block>
<script>
<![CDATA[
function sayasDigits(number)
{
var digitNumber = number.charAt(0);
for(var i = 1; i < number.length; i++)
{
digitNumber += ' ' + number.charAt(i);
}
return digitNumber;
}
]]>
</script>
<prompt>
Hello there. The caller i d value is: <value expr="sayasDigits(session.callerid)"/>
The called i d of this application is: <value expr="sayasDigits(session.calledid)"/>
</prompt>
</block>
</form>
</vxml>
<script> element | ANNOTATIONS: EXISTING POSTS |
alvaro
|
|
| Hi! I'm Alvaro and I would like to know how to create a text file(.txt) in an VoiceXML application to store data. May someone help me? If it's possible I would prefer a practical example with a little explanation. I am novate. Thanks. | |
VoxeoDenise
|
|
| Hey Alvaro,
In order to write to a text file using VoiceXML, you will need to implement some sort of Server Side Language such as PHP, ASP, JSP, or Cold Fusion. Hopefully this will help to get you started. Please feel free to contact us if you have any further questions. Regards, Denise Rodriguez Voxeo Extreme Support |
|
alvaro
|
|
| Thanks for your answer.
Now a have another doubt. I want to store data in this URL: http://localhost/....../reserva.php?info1=..&info2=..&info3=.. and I have tried with the submit element but it doesn`t work and I would like to know if there is another element or another way using submit to do this. With submit I have use the "next" attribute and/or the "namelist" attribute. |
|
Don.Lawson
|
|
| Alvaro,
The namelist attribute specifies a space-separated list of variables to send to the URI indicated by the next or expr attributes. Note that if the namelist attribute is left unspecified, then all input-item variables will be submitted to the destination URI. So for your case <submit next="http://localhost/....../reserva.php" namelist="info1 info2 info3" /> And of course if you leave the namelist attribute out of it, all of the variables will be past along. You can also specify a method attribute to make it a POST request. It defaults to GET so if your php script is expecting POST you will need to specify this. Also in your php script make sure you are using the $_REQUEST global variable instead of $_POST as it will eliminate any error related to this. Don Lawson Voxeo Support |
|
anil.s
|
|
| Hi,
I am Anil.. I am not able to figure it out why i am getting the following error. Please post me in which scenarios generally the voice xml end up with these kind of errors. "Cannot read property "termchar" from undefined (JSI#1)" Thanks, Anil |
|
voxeojeremyr
|
|
| Hi Anil,
I am not familiar with that error. I think that you are trying to set the termchar property and that there is some kind error when trying to set the value. To help us troubleshoot this more effectively, could you open an account ticket and attach your code and a debugger log? Thanks, Jeremy Richmond Voxeo Support |
| login |
|