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

Star to return to the main menu

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
jcooper
Posts: 45
Joined: Tue Jul 22, 2008 5:22 pm

Star to return to the main menu

Post by jcooper »

I'm trying to implement allowing the users to press star (*) to return to the main menu. I added a grammar with a public scope to the form

Code: Select all

<grammar type="application/srgs+xml" root="goback" mode="dtmf" version = "1.0">
				<rule id="goback" scope="public">
					<one-of>
						<item>*</item>
					</one-of>
				</rule>
			</grammar>
but when i press * in a field that is set to handle it it just re-prompts without actually entering the <filled> tag.
Any ideas?
Thanks!

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

IVR code for grammar issue

Post by support »

Hi,

You would have to put quotation marks around the * key in order for it to be recognized.

You can use the following IVR code example to help you accomplish this. Note the IVR <grammar> within the IVR example.

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">

<form id="mainmenu">
  <block>
    <prompt>
      Welcome to the main menu!
    </prompt>
    <goto next="#starfield"/>
  </block>
</form>

<form id="starfield">
  <field name="key">
    <grammar type="application/srgs+xml" root="goback" mode="dtmf" version = "1.0">
      <rule id="goback" scope="public">
        <one-of>
          <item>1</item>
          <item>2</item>
          <item>3</item>
          <item>4</item>
          <item>5</item>
          <item>6</item>
          <item>7</item>
          <item>8</item>
          <item>9</item>
          <item>0</item>
          <item>"#"</item>
          <item>"*"</item>
        </one-of>
      </rule>
    </grammar>

    <prompt>
      Please enter a key.
    </prompt>

    <filled>
      <prompt>
        You entered <value expr="key"/>.
      </prompt>
      <if cond="key=='*'">
        <goto next="#mainmenu"/>
      <else/>
        <prompt>
          Goodbye!
        </prompt>
      </if>
    </filled>
  </field> 
</form>
</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Wed Feb 17, 2010 12:14 pm, edited 5 times in total.

jcooper
Posts: 45
Joined: Tue Jul 22, 2008 5:22 pm

Post by jcooper »

Thanks.. one more question. If I expected a 6 digit number how would i make this grammar work? I know there is a repeat option for each item but I think that would allow me to enter six of the same number (e.g. '666666').

Currently the form grammar is the built in 'digits' grammar.
Thanks.

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

IVR code for grammar fix

Post by support »

Hi,

You could use the following IVR code example to help you accomplish this. Note the <if> conditionals below.

digits.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">

<form id="mainmenu">
  <block>
    <prompt>
      Welcome to the main menu!
    </prompt>
    <goto next="#starfield"/>
  </block>
</form>

<form id="starfield">
  <field name="input">
    <grammar root="ROOT" type="application/srgs+xml" mode="dtmf">
      <rule id="ROOT" scope="public">
        <one-of>
            <item repeat="0-255">
              <ruleref uri="#digit"/>
            </item>
          <item> "* #" </item>
          <item> "#" </item>
        </one-of>
      </rule>

      <rule id="digit" scope="public">
        <one-of>
          <item> 0 </item>
          <item> 1 </item>
          <item> 2 </item>
          <item> 3 </item>
          <item> 4 </item>
          <item> 5 </item>
          <item> 6 </item>
          <item> 7 </item>
          <item> 8 </item>
          <item> 9 </item>
          <item> "*" </item>
          <item> "#" </item>
        </one-of>
      </rule>
    </grammar>

    <prompt>
      Please enter some digits.
    </prompt>
    <filled>
      <assign name="input" expr="input.replace(/ /g, '')"/>
      <if cond="input == '*'">
        <goto next="#mainmenu"/>
      <elseif cond="input.length == 6"/>
        <prompt>
          You entered <say-as type="acronym"><value expr="input"/></say-as>. Thank you for entering exactly 6 digits.
        </prompt>
      <else/>
        <prompt>
          You entered <say-as type="acronym"><value expr="input"/></say-as>. You have entered an incorrect amount of digits.
        </prompt>
        <clear namelist="input"/>
      </if>
    </filled>
  </field>
</form>
</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Tue Jan 12, 2010 4:01 pm, edited 3 times in total.

jcooper
Posts: 45
Joined: Tue Jul 22, 2008 5:22 pm

Post by jcooper »

Awesome thanks!!

Post Reply