Page 1 of 1

Dynamic Menu

Posted: Mon Apr 09, 2007 3:23 pm
by shanthint@paydq.com
Hello,

I need to get the menu dynamically from the web server as a
script array. Any help is appreciated.

Thanks

dynamically generating IVR script

Posted: Tue Apr 10, 2007 10:10 am
by support
Hello,

You should be generating the VoiceXML dynamically using server side scripting. By dynamically generating the IVR script you will be able to easily create the menu on the fly. Starting from a static script and attempting to assemble the menu using ECMAScript is extremely complex and not the recommended means of working with VoiceXML. An IVR example of a dynamically generated menu using php would be:

Code: Select all

<?php
$choices[] = Array("name"=>"sales", "url"=>"sales.php");
$choices[] = Array("name"=>"support", "url"=>"support.php");
$choices[] = Array("name"=>"company directory", "url"=>"company.php");

echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
	<menu>
		<prompt>
			<enumerate>
				For <value expr="_prompt"/>, press <value expr="_dtmf"/>.
			</enumerate>
		</prompt>
		<?php
			foreach ($choices as $choice) {
				echo("<choice next=\"".$choice['url']."\">".$choice['name']."</choice>\n");
			}
		?>
	</menu>
</vxml>
Regards,
Plum Support

Dynamic Menu

Posted: Tue Apr 10, 2007 10:30 am
by shanthint@paydq.com
Thank you. I will try that.
One more question about that.
Actually I am using subdialog tag to connect to the web server.
In this case, Don't i need to return something from the server instead of looping through the script array there itself?.

Dynamic Menu

Posted: Tue Apr 10, 2007 10:32 am
by shanthint@paydq.com
And one more thing I am using JSP in the server side.

to collect input, use a field with IVR grammar

Posted: Tue Apr 10, 2007 11:59 am
by support
Hello,

Can you please provide a more detailed explanation of what you are trying to do? Normally you would not use a menu within a subdialog. Menus are provided to allow for shortcuts to jump between different pages, not for collecting input from the user. If you want to collect input it is recommended that you instead use a field with an IVR grammar. We do not have any internal expertise in JSP so we will not be able to provide you with JSP based examples.

Regards,
Plum Support

Dynamic Menu

Posted: Tue Apr 10, 2007 2:32 pm
by shanthint@paydq.com
I am sorry for not providing enough information.

Here is what I am trying to do.

I am gettting input from user and sending that to the webserver
for authentication using subdialog tag and from web server
I am sending some data as a response to the interpreter context using return tags. menu array is one of those response data from the server. And in the interpreter context I have to loop through the array for the dynamic menu. Is there any way to do it like using
data tag or something? somehow I have to get the control back to interpreter context with the response data.

Thank you.

Posted: Tue Apr 10, 2007 2:34 pm
by shanthint@paydq.com
And I forgot to mention it that I am not going to use menu inside the subdialog. I can assign those variables as global variable and I can loop through it outside the subdialog tag.

IVR Programmer's Reference Manual shows how to loop through

Posted: Tue Apr 10, 2007 3:02 pm
by support
Hello,

The IVR problem you will have in trying to use a menu in a dynamic way is that there is no way to generate the <choice> elements without using server side scripting. You should instead mimic the behavior of a menu using the <field> tag and dynamically generating the prompts using a <foreach> tag. The <foreach> tag can be used to traverse an array and then play back each element of the array. The IVR example in the Plum IVR Programmer's Reference Manual shows how to loop through array data, you would just have to return the array data from your subdialog.

There is no way to specify a dynamically generated IVR grammar, you'd be better off specifying the IVR grammar as type="digits?length=1" and then checking the return value in the <filled>block:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
   <form>
      <!-- ASSUMES THE SUBDIALOG RETURNS AN ARRAY OF OPTIONS -->
      <subdialog name="options" src="somescript.php"/>

      <var name="count" expr="1"/>
      <field name="fakemenu" type="digits?length=1">
         <prompt>
            <foreach array="options" item="option">
               For <value expr="options.prompt"/>, press <value expr="count++"/>.
            </foreach>
         </prompt>
         <filled>
            <if cond="fakemenu > options.length">
               <clear/>
               <reprompt/>
            <else/>
               <!-- STORE THE RESPONSE AND GO TO THE NEXT SECTION -->
            </if>
         </filled>
      </field>
   </form>
</vxml>
Regards,
Plum Support

Posted: Thu Apr 12, 2007 1:43 pm
by shanthint@paydq.com
This dynamic menu is working with little modification.


Thank you.

Posted: Fri Apr 20, 2007 8:29 am
by shanthint@paydq.com
Hello,

I am wondering that is it possible to get both dtmf and voice using the foreach array dynamic menu that we were talking before.?
Now the dynamic menu is working only for dtmf.but not for voice response.

Thank you.

IVR developer explains why dynamice menu won't work

Posted: Fri Apr 20, 2007 9:19 am
by support
It will not work for voice because you need a voice specific IVR grammar like one that the IVR platform utilzes to listen for the different utterances. Such an IVR grammar is static and needs to be explicitly specified within a <grammar> tag.