Dynamically Create Grammar
Posted: Mon Apr 20, 2015 10:27 pm
I wish to dynamically create a different grammar for each field depending on the value of a specific field. I apologize for the "pseudo-code" below, but I'm away from work and do not have the exact code with me. I am presenting the person with a series of questions (dynamically produced). And each question has a different set of choices/answers. Some questions may be of boolean type, while others may be digit (0-9), while still others may be number. Therefore, I want to dynamically create/present the grammar per question.
In Code Behind, I evaluate a value and assign a grammar such as
And in ASPX page I'm trying to do something like this...
When I try to do this I get the following error...
(This initial line is correctly spoken--it is the vxml that is returned via the variable "questionOptions" above)
<?xml version='1.0'?><speak>Press or say a number between 0 and 120.</speak>
---------
VXI::field_element - activating grammars for form = 'questionForm' formitem = 'qAnswer'
Cache Miss: http://MYSERVER/playGreeting.aspx
Attempting to fetch http://MYSERVER/playGreeting.aspx
HTTP/1.1 500 Internal Server Error - http://MYSERVER/playGreeting.aspx
Failure in inetptr->Open call in OSBrecLoadGrammarFromURI constructor
received event: error.badfetch.http.500:
Is it possible to dynamically create/present grammars? I'm not trying to use any "special" grammars--just the typical built-in grammars, but do need the ability to switch them depending on the type of question being asked--which isn't known until into the application.
Thanks for any assistance!
In Code Behind, I evaluate a value and assign a grammar such as
Code: Select all
If(questionDataType ==1) //boolean
{
IVRSession.gExpression = “builtin:grammar/boolean”;
}
else if(questionDataType==2) //number greater than 9
{
IVRSession.gExpression = “builtin:grammar/number”;
}
else if(questionDataType==3) //number between 0 and 9
{
IVRSession.gExpression = “builtin:grammar/digits”;
}
Code: Select all
<var name ="qGrammar" expr="<%=IVRSession.gExpression%>" />
//some other code that works....
<field name=qAnswer>
<grammar srcexpr="qGrammar" />
<prompt>
<value expr="questionOptions"/> (THIS IS A VARIABLE ESTABLISHED EARLIER THRU ANOTHER SUBDIALOG AND WORKS)
</prompt>
</field>
(This initial line is correctly spoken--it is the vxml that is returned via the variable "questionOptions" above)
<?xml version='1.0'?><speak>Press or say a number between 0 and 120.</speak>
---------
VXI::field_element - activating grammars for form = 'questionForm' formitem = 'qAnswer'
Cache Miss: http://MYSERVER/playGreeting.aspx
Attempting to fetch http://MYSERVER/playGreeting.aspx
HTTP/1.1 500 Internal Server Error - http://MYSERVER/playGreeting.aspx
Failure in inetptr->Open call in OSBrecLoadGrammarFromURI constructor
received event: error.badfetch.http.500:
Is it possible to dynamically create/present grammars? I'm not trying to use any "special" grammars--just the typical built-in grammars, but do need the ability to switch them depending on the type of question being asked--which isn't known until into the application.
Thanks for any assistance!