Page 1 of 1

Star to return to the main menu

Posted: Thu Dec 18, 2008 9:17 pm
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!

IVR code for grammar issue

Posted: Fri Dec 19, 2008 10:04 am
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

Posted: Fri Dec 19, 2008 7:45 pm
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.

IVR code for grammar fix

Posted: Mon Dec 22, 2008 11:03 am
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

Posted: Tue Dec 23, 2008 8:08 pm
by jcooper
Awesome thanks!!