Monday, March 29, 2010

VXML Getting Started, VXML fundamental, VXML easy example

VXML (=Voice XML)
Ref: http://www.ibm.com/developerworks/library/wa-voicexml/


Java is very famous for develop web application. In web application we will have UI and we can enter any dataor fetch data using that UI. Nowadays Phone or mobiel are very common, so we should have some technology to access our java code using the mobile and that is called VXML technology.


A simple VXML page (Say First.vxml)
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">
<form>
<block>
<prompt> Hi Binod your first VXML Applciationi is working fine, Congratulations. </prompt>
</block>
</form>
</vxml>

Save this file say (D:\Binod)

You can check your vxml syntax here at cafe.bevocal.com. First need registration then you can check your code here itself. Really very nice.

To access this file, we have to upload this file for publically accessible. Some vxml interpreter should be thereto understand all vxml tags. The famous server is telco server. But to run vxml example from home or for learing purposem, we can use https://evolution.voxeo.com/ site.
Unlike traditional Web applications, you can't just open up a Web browser and surf on over to your VXML file; at least, not if you want a voice response. To test out a phone-based application, you obviously need a phone, and that implies a number to call. There are plenty of high-dollar approaches to mapping numbers to VoiceXML applications, but for testing, staging, and development, Voxeo offers a great free mapping service.
Navigate over to http://evolution.voxeo.com/,create username and password and log in (using the fields on the upper left side of the page). Under Account menu, select File, Logs, & Report option -> doulbe click on www -> go to first upload file secion and click on Browse and choose d:\Binod\First.vxml click open. Now click on Upload button.
Again click on Account menu then click on Application Manager ->

Add Application Give any name to your application say Binod_First_IVRThen click on Voice Phone Calls option, DONT change any option in voice application type. in Voice URLclick on file manager hyperlink you will be getting here your uploade file First.vxml, select this fileand click on map button. DONOT change any thing in Phone number combo box. Simple click on Create Application button.

You will be getting one mail to your mail box. :)

click on Contact Methods tab.copy Skype voip number and dial same number from your skype account.(If you dont have skype account then please go to http://www.skype.com/ and download skype and create one account then only you will be able to call this number).

If you want to edit your vxml file then Account -> Aplication Manager -> click on Binod_First_IVR, click on edit file (option is near to * Voice URL)Once file will get open you can change and just click on save change. Now you can check your new update after calling from skype.

For debugging: Account -> Application Debugger now call from skype then data will be show here in debugger.

Some other example on Input.
Second.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">

<field name="xx" type="digits">
<prompt>
welcome to ivrs process BY Binod.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>

<filled>

<if cond="xx==1"> <prompt> YOU HAVE ENTERD ENGLISH </prompt> <elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> <else/> <prompt> Please choose correct option </prompt>
</if>
</filled>
</field>
</form>
</vxml>

Some more advacne input program.

If user does not give correct input then it should repromt for 3 times.

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">
<prompt>
welcome to TecnoTree IVR.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>
<filled>

<if cond="xx==1">
<prompt> YOU HAVE ENTERD ENGLISH </prompt>
<elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> </if> </filled> </field>
<noinput>
<prompt> We didnt get any input from you </prompt>
<reprompt/>

</noinput>
<nomatch>
<prompt> not a valid input</prompt> <reprompt/> </nomatch>

<nomatch count="3">
<prompt> You have reached maximum tried</prompt> <exit/> </nomatch>
</form>
</vxml>
This will only work for * or # incase of no match.

Another Example:
Take one input and prompt same number:

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">

<prompt> Enter any digit </prompt>
<filled>
<prompt> you have entered <value expr="xx"/> </prompt> </filled>
</field>
</form>
</vxml>

calculator.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<var name="x" expr="0"/>
<var name="y" expr="0"/>
<!-- <var name="zz" expr="0"/> -->
<field name="xx" type="number">
<prompt>Welcome to IVR Calculator. Enter any digit </prompt>

<filled>
<assign name="x" expr="xx"/>
<prompt> you have entered <value expr="xx"/> </prompt>
<goto nextitem="yy"/>
</filled>
</field>

<field name="yy" type="number">
<prompt> <break time="2s"/> Enter Second any digit </prompt> <filled> <assign name="y" expr="yy"/>
<script>
var zz= Number(x)+Number(y);
</script>
<prompt> you have entered Second digit <value expr="yy"/>
<!-- Now the total value <value expr="xx+yy"/> -->
</prompt>
<!-- <assign name="zz" expr="Number(x)+Number(y)"/> --> <prompt> <break time="2s"/> The Answer after addition two number is <value expr="zz"/> </prompt>
</filled>
</field>

<field name="again" type="number">
<prompt> <break time="1s"/>
Press 1 for add another number.
Press 2 for exit.
</prompt>
<filled>
<if cond="again==1"> <prompt> YOU HAVE SELECTED ONE </prompt> <goto nextitem="xx"/>
<elseif cond="again==2"/> <prompt> YOU HAVE SELECTED TWO </prompt> <exit/>
</if>
</filled>
</field>
</form>
</vxml>

Recording Example
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<form id="F1">
<record name="R_1" beep="true" dtmfterm="true">
<prompt> Good Morning. Welcome to Binod Suman IVR. You can record your message after hear beep.
</prompt>

<prompt> after you are finished, Please press hash button </prompt>

<filled> <log expr="R_1$.duration"/> <log expr="R_1$.termchar"/> <log expr="R_1$.size"/>
<prompt> your recording was <value expr="R_1"/> THANK YOU FOR USING BINOD IVR APPLICATION. </prompt> </filled>
</record>
</form>
</vxml>

2 comments:

  1. Hi Binod,

    Do you know how to parse vxml response like the one you do in your post "Parse XML response in JavaSript". I want to parse vxml in servlet. If you can point me the right way, it will be much appreciated. Thanks in advance.

    puzz

    ReplyDelete
  2. Hi,
    Where r u right now I did not get new blogs from your side. Please give some example of jsf and integration of Spring and hibernate in easy step.

    Great Job.

    ReplyDelete

You can put your comments here (Either feedback or your Question related to blog)