We've used this IVR code and it's worked fine for us. Note the IVR <grammar> implementations below.
Code: Select all
<?xml version="1.0"?>
<vxml version="2.0">
<var name="AM_PM" expr="''"/>
<var name="SayH" expr="''"/>
<var name="H" expr="''"/>
<!-- /////////////////////// GET CALL Hour /////////////////////// -->
<form id="Hour_To_CallGreeting">
<block >During which hour of the day would you like to receive your reminder phone call. Let's begin by choosing an AM or PM call.
<goto next="#Choose_AM_PM"/></block>
</form>
<form id="Choose_AM_PM">
<field name="AM_or_PM">
<grammar type="application/x-jsgf" mode="voice">
( ((A M | morning) {AM}) |
((P M | afternoon | evening | night) {PM} ) )
</grammar>
<grammar type="application/x-jsgf" mode="dtmf">
(1 {AM} | 2 {PM} )
</grammar>
<prompt bargein="true" timeout="2s">
For
A.M. - Press 1, or say "A.M.".
P.M. - Press 2, or say "P.M.".
</prompt>
<catch event="nomatch noinput">
<reprompt />
</catch>
<filled>
<if cond = "AM_or_PM == 'AM'">
<assign name="AM_PM" expr="'AM'"/>
<else/>
<assign name="AM_PM" expr="'PM'"/>
<assign name="PM" expr="12"/>
</if>
<prompt>
Thank you. You chose <value expr="AM_PM"/>
</prompt>
<goto next="#VerifyAM_PM"/>
</filled>
</field>
</form>
<menu id="VerifyAM_PM">
<prompt bargein="true" timeout="2s">
Is that correct? Yes or no? press 1 for yes or 2 for no.
</prompt>
<choice dtmf="1" next="#Hour_To_Call" accept="approximate">yes yeah yep yup sure correct right</choice>
<choice dtmf="2" next="#Choose_AM_PM" accept="approximate">wrong no nope not na nadda</choice>/>
</menu>
<catch event="noinput">
<!-- Sorry, I did not hear anything. Press 1 for yes or 2 for no. -->
<reprompt />
</catch>
<!-- /////////////////////// call_hour ///////////////////////////// -->
<form id="Hour_To_Call">
<field name="hour">
<grammar type="application/x-jsgf" mode="voice">
(
((1 | one ) {01}) |
((2 | two) {02}) |
((3 | three) {03}) |
((4 | four) {04}) |
((5 | five ) {05}) |
((6 | six) {06}) |
((7 | seven) {07}) |
((8 | eight) {08}) |
((9 | nine) {09}) |
((10 | ten) {10}) |
((11 | eleven) {11}) |
((12 | twelve) {12})
)
</grammar>
<grammar type="application/x-jsgf" mode="dtmf">
(1 {01} | 2 {02} | 3 {03} | 4 {04} | 5 {05} | 6 {06} | 7 {07} | 8 {08} | 9 {09} | 10 {10} | 11 {11} | 12 {12} )
</grammar>
<prompt bargein="true" timeout="3s">
Using your keypad enter the hour you would like to receive your reminder phone call, or just say it.
</prompt>
<filled>
<if cond = "hour == 1"> <assign name="H" expr="1"/>
<elseif cond = "hour == 2"/> <assign name="H" expr="2"/>
<elseif cond = "hour == 3"/> <assign name="H" expr="3"/>
<elseif cond = "hour == 4"/> <assign name="H" expr="4"/>
<elseif cond = "hour == 5"/> <assign name="H" expr="5"/>
<elseif cond = "hour == 6"/> <assign name="H" expr="6"/>
<elseif cond = "hour == 7"/> <assign name="H" expr="7"/>
<elseif cond = "hour == 8"/> <assign name="H" expr="8"/>
<elseif cond = "hour == 9"/> <assign name="H" expr="9"/>
<elseif cond = "hour == 10"/> <assign name="H" expr="10"/>
<elseif cond = "hour == 11"/> <assign name="H" expr="11"/>
<else/>
<assign name="H" expr="12"/>
</if>
<if cond="H == 12">
<goto next="#NoonOrMidnight"/>
<elseif cond ="AM_PM == 'PM'"/>
<assign name="call_hour" expr="H + 12"/>
<assign name="SayH" expr="H + ' ' + AM_PM"/>
<else/>
<assign name="call_hour" expr="H"/>
<assign name="SayH" expr="H + ' ' + AM_PM"/>
</if>
<prompt>
Thank you. You entered <value expr="SayH"/>
</prompt>
<goto next="#Verifyhour"/>
</filled>
<catch event="noinput">
Sorry, I did not hear anything.
<reprompt />
</catch>
</field>
</form>
<menu id="NoonOrMidnight">
<prompt bargein="true" timeout="2s">Just to be sure I have it right. Did you mean noon, or midnight?
If you meant 12 noon, say noon, or press 1.
If you meant 12 midnight, say midnight, or press 2.
</prompt>
<choice dtmf="1" next="#Noon" accept="approximate">noon</choice>
<choice dtmf="2" next="#Midnight" accept="approximate">midnight</choice>
</menu>
<catch event="noinput">
Sorry, I did not hear anything.
<reprompt />
</catch>
<form id="Noon">
<block>
<assign name="call_hour" expr="12"/>
<var name="SayH" expr="'12 Noon'"/>
<goto next="#PostVerifyHour"/>
</block>
</form>
<form id="Midnight">
<block>
<assign name="call_hour" expr="00"/>
<var name="SayH" expr="'12 Midnight'"/>
<goto next="#PostVerifyHour"/>
</block>
</form>
<menu id="Verifyhour">
<prompt bargein="true" timeout="2s">
Is that correct? Yes, or no? Press 1 for yes or 2 for no.
</prompt>
<choice dtmf="1" next="#PostVerifyHour" accept="approximate">yes yeah yep yup sure correct right</choice>
<choice dtmf="2" next="#Hour_To_Call" accept="approximate">wrong no nope not na nadda</choice>
</menu>
<catch event="noinput">
Sorry, I did not hear anything.
<reprompt />
</catch>
<form id="PostVerifyHour">
<block>
<prompt bargein="false">
Okay, I'll be calling you between <value expr="H"/> and <value expr="H + 1"/> <value expr="AM_PM"/>.
</prompt>
</block>
</form>
</vxml>
Plum Support