Processing Input (VoiceXML for Web Developers)
Monday, January 4th, 2010This post is part of a series exploring voice applications and VoiceXML through the eyes of a web developer. For the rest of the series, see the index.
If you want to follow along with these examples, you should create a free VoiceXML hosting account in Evolution. Complete instructions were in the first installment of the series.
Today I’m continuing the development of our application for the fictional Strato Pizza. Previously, I asked the caller for their pizza topping preference and their phone number, using both speech recognition and touch tone input. Today I’m going to do something with that input, and repeat the order to the customer.
Within VoiceXML, I can access the values of any fields with <value expr="fieldName$.utterance"/>. This code will return the matched value from my grammar.
Since I want to simply repeat the order and the phone number, I’m going to add a <block> element to my existing form. Inside the block, I’ll add a <prompt> element with the text I want to speak.
<block>
<prompt>
You ordered <value expr="topping$.utterance"/> on your pizza.
</prompt>
</block>
When the VoiceXML browser reaches this line, it will speak my text, substituting whatever the caller said in response to the field named topping for topping$.utterance. If the caller asked for ham, the spoken text will be just like if my prompt said, “You ordered ham on your pizza.”
You can use multiple value expressions in a single prompt. I also want to tell the customer that they’ll get a call if there’s a problem with their order. I’ll repeat their phone number to them. Then I’ll thank them for their order and hang up.
<block>
<prompt>
You ordered <value expr="topping$.utterance"/> on your pizza. If we have any questions we will call you at <value expr="phone$.utterance"/>. Thank you for your order.
</prompt>
</block>
Remember that for the phone number field, I allowed the caller to use either voice or touch tone input with a built in grammar like so:
<field name="phone" type="phone">
Please say or enter your phone number.
</field>
When I access this value with <value expr="phone$.utterance"/> it doesn’t matter if the caller used voice or DTMF input. The grammar gives the same result. So when I read back the phone number, they’ll hear the digits of their phone number spoken back to them.
You can get the code for this example and all other examples from Voxeo’s GitHub account. At GitHub, you can fork or download the VoiceXML application thus far.
Want to learn how Voxeo can help unlock your communications and deliver
a better customer experience?
Please contact us!
If you found this post interesting or helpful, please consider either
subscribing via RSS, becoming
a fan on Facebook, or
following us on Twitter.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=6cfd76c1-598b-4191-bfed-84418a81fdba)





![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=bf042a9f-b25f-4867-8f2d-f7364ac3b376)
RSS Feed




