We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Dynamic Menu

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Dynamic Menu

Post 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

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

dynamically generating IVR script

Post 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
Last edited by support on Sat Feb 20, 2010 3:03 pm, edited 3 times in total.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Dynamic Menu

Post 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?.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Dynamic Menu

Post by shanthint@paydq.com »

And one more thing I am using JSP in the server side.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

to collect input, use a field with IVR grammar

Post 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
Last edited by support on Wed Dec 30, 2009 3:59 pm, edited 1 time in total.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Dynamic Menu

Post 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.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR Programmer's Reference Manual shows how to loop through

Post 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
Last edited by support on Wed Feb 24, 2010 5:44 pm, edited 4 times in total.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Post by shanthint@paydq.com »

This dynamic menu is working with little modification.


Thank you.

shanthint@paydq.com
Posts: 84
Joined: Wed Apr 04, 2007 4:58 pm

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR developer explains why dynamice menu won't work

Post 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.

Post Reply