How Tos

Last reviewed: 9/1/2012

Article ID: H031308

HOW: Dynamically generating VoiceXML with VoiceXMLKit

The information in this article applies to:

  • VoiceXMLKit

Summary

End users typically interact with VoiceXML applications running on servers over a phone connection.

VoiceXMLKit provides components for dynamically generating VoiceXML documents so interactive voice response applications can adapt at runtime.

More Information

The VoiceXMLKit conversation management component is designed to provide you a lot of flexiblity and minimize the programming necessary to dynamically generate VoiceXML.

To create a VoiceXML document, use the CreateDocument method to create the base VoiceXML document object to which to add VoiceXML elements. For example:

NChantVxmlDocument vxmlDocument = NChantXM1.CreateDocument();
NChantVxmlVxml vxml = vxmlDocument.AddVxml();
vxml.Version = "2.0";
// Add Menu
NChantVxmlMenu menu = vxml.AddMenu();
menu.Dtmf = true;
// Add Prompt
NChantVxmlPrompt prompt = menu.AddPrompt();
prompt.AddText("To hear today's specials, first select a department.");
NChantVxmlEnumerate enumerate = prompt.AddEnumerate();
enumerate.AddText("Say");
NChantVxmlValue value = enumerate.AddValue();
value.Expr = "_prompt";
enumerate.AddText(", or press");
value = enumerate.AddValue();
value.Expr = "_dtmf";
enumerate.AddText(". ");
// Add Choices
NChantVxmlChoice choice = menu.AddChoice();
choice.Event = "deli";
choice.AddText("Deli and Bakery");
choice = menu.AddChoice();
choice.Event = "produce";
choice.AddText("Fresh Produce");
choice = menu.AddChoice();
choice.Event = "meat";
choice.AddText("Meat and Seafood");
// Add a menu selection as user event handler
NChantVxmlCatch catchuserevent = menu.AddCatch();
catchuserevent.Event = "deli";
// Lookup Deli and Bakery specials
catchuserevent.AddText(GetDeliSpecials());
// Add return variables
NChantVxmlReturn menuReturn = catchuserevent.AddReturn();
menuReturn.Namelist = "_event";
// Add a menu selection as user event handler
catchuserevent = menu.AddCatch();
catchuserevent.Event = "produce";
// Lookup Fresh Produce specials
catchuserevent.AddText(GetProduceSpecials());
// Add return variables
menuReturn = catchuserevent.AddReturn();
menuReturn.Namelist = "_event";
// Add a menu selection as user event handler
catchuserevent = menu.AddCatch();
catchuserevent.Event = "meat";
// Lookup Meat and Seafood specials
catchuserevent.AddText(GetMeatSpecials());
// Add return variables
menuReturn = catchuserevent.AddReturn();
menuReturn.Namelist = "_event";
// Add catchall handler
NChantVxmlCatch catchall = menu.AddCatch();
catchall.Event = "noinput nomatch";
catchall.AddReprompt();
            

To dynamically generate the VoiceXML, use the GenerateVXML method to create the base VoiceXML document. For example:

// Get the VoiceXML
string specialsVXML = vxmlDocument.GenerateVXML(ChantVXMLVersion.CVVAll);
// Delete the document object
vxmlDocument.Dispose();

For additional help with VoiceXMLKit, contact Chant Support via Chant Support Contacts or web.

LexiconKit 5 Upgrade to LexiconKit 5

Tailor pronunciations for maximum clarity when recognizing and synthesizing.

Learn moreLearn more DownloadDownload Buy US $499Buy US $499
Plantronics Savi 440 Plantronics Savi 440 wireless headset

  • Noise-Canceling microphone
  • Range up to 300 feet
  • 7 hours talk time
  • USB charging cradle
  • Wearing options: over the head, over the ear, behind the neck, and dual T-pad headband

Learn moreLearn more