Page 1 of 3

Problems with </elseif> & </if>

Posted: Wed Aug 13, 2008 7:56 am
by Chris
I keep getting error messages about </elseif> & </if>
The errors don't seem logical.

And I get different errors from the Log File vs the Scratchpad.

Log File reports:
"No character data is allowed by content model -- LINE 120 COL 1"

Scratchpad says:
"Element elseif was declared EMPTY this one has content in Entity, line: 126"

What's wrong with this code?

<if cond = "H == 12">
<goto next="#HH"/>
LINE 120 <elseif cond ="XX == PM">
<assign name="hour" expr="H + PM"/>
<var name="SayH" expr="H + XX"/>
<else/>
<assign name="hour" expr="H"/>
<var name="SayH" expr="H + XX"/>
LINE 126 </elseif>
</if>

Code: Select all

<if cond = "H == 12">
<goto next="#HH"/>
<elseif cond ="XX == PM">
<assign name="hour" expr="H + PM"/>
<var name="SayH" expr="H + XX"/>
<else/>
<assign name="hour" expr="H"/>
<var name="SayH" expr="H + XX"/> 
</elseif>
</if>

IVR script example to correctly use tags

Posted: Wed Aug 13, 2008 9:58 am
by support
Hi Chris,

The reason you are getting this IVR error: "Element elseif was declared EMPTY this one has content in Entity, line: 126"

is because you are using the IVR tag, <elseif>, incorrectly. The VoiceXML specification defines that the <elseif> and <else> tags cannot have inner content, so they are not allowed to have to have a closing tag to them (</elseif> and </else>).

If you remove the </elseif> from your IVR code, this should get rid of the IVR error.

Regards,
Plum Support

Posted: Wed Aug 13, 2008 10:36 am
by Chris
I already went down that road.
But to follow your advice, I removed the </endif> once again.
The result is yet another error !!!

Opening and ending tag mismatch: elseif line 120 and if in Entity, line: 127

118 <if cond = "H == 12">
119 <goto next="#HH"/>
120 <elseif cond ="AM_PM == PM">
121 <assign name="hour" expr="H + PM"/>
122 <var name="SayH" expr="H + XX"/>
123 <else/>
124 <assign name="hour" expr="H"/>
125 <var name="SayH" expr="H + XX"/>
126
127 </if>

IVR code to fix user error

Posted: Wed Aug 13, 2008 10:38 am
by support
Hi Chris,

We looked at this line:

Code: Select all

<elseif cond ="AM_PM == PM">
and noticed you were missing a "/". You should edit this line to this, as shown in our IVR code examples from the documentation:

Code: Select all

<elseif cond ="AM_PM == PM"/>
Regards,
Plum Support

Posted: Wed Aug 13, 2008 11:13 am
by Chris
Thank you/>
It's the smallest of creatures that reek the most havoc.

ReferenceError: AM is not defined line 1

Posted: Wed Aug 13, 2008 11:49 am
by Chris
Since I stopped getting errors in the Scratchpad,
and you solved the last problem,
I thought I had this down perfectly.
I'm even proud of my work.

But !!!
When I call in I get an error
"ReferenceError: AM is not defined line 1"
And it doesn't matter if I choose AM or PM or 1 or 2
I get the same error about AM.

Can you tell where the problem is?

Code: Select all

 <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">
 <var name="AM_PM" expr="AM"/>
<else/>
 <var name="AM_PM" expr="PM"/>
 <var name="PM" expr="12"/>
</if>

 <prompt>
 Thank you. You chose <value expr="AM_PM"/>
 </prompt>
 <goto next="#VerifyAM_PM"/>
 </filled>

 </field>
 </form>

IVR system and variables vs strings

Posted: Wed Aug 13, 2008 2:56 pm
by support
Hi Chris,

The reason you are getting this IVR error is because of your <filled> block. You should edit it to something more like this:

Code: Select all

<filled>
 <if cond = "AM_or_PM == 'AM'">
   <var name="AM_PM" expr="'AM'"/>
 <else/>
   <var name="AM_PM" expr="'PM'"/>
   <var name="PM" expr="12"/>
 </if>

<prompt>
 Thank you. You chose <value expr="AM_PM"/>
</prompt>
<goto next="#VerifyAM_PM"/>
</filled>
If you do not use quotes ('') around AM, then the IVR system mistakes it for a variable instead of a string, which is what you want.

Regards,
Plum Support

Posted: Thu Aug 14, 2008 10:21 am
by Chris
Thank you!
That was a good fix. I never would have figured that one out myself.


Now I'm running into some errors which I just don't understand, because variables that are defined are coming back as undefined.
Go figure?

When selecting 12 Noon the following error is returned:
Thu 14 Aug 2008 10:30:25 AM EDT:
Found grammar match
hypothesis #0: noon (0.7350)
hypothesis #1: midnight (0.2360)
VXI::assign_element(name="call_hour" expr = "12")
VXI::var_element(name="SayH" expr = "'12 Noon'")
ReferenceError: SayH is not defined line 1
received event: error.semantic.ecmascript:
How can it return such an error if "SayH" expr = "'12 Noon'"?

When selecting 12 Midnight the following error is returned:
Thu 14 Aug 2008 10:40:15 AM EDT:
Found grammar match
hypothesis #0: midnight (0.9850)
hypothesis #1: noon (0.0110)
VXI::assign_element(name="call_hour" expr = "00")
VXI::var_element(name="SayH" expr = "'12 Midnight'")
ReferenceError: SayH is not defined line 1
received event: error.semantic.ecmascript:
How can it return such an error if "SayH" expr = "'12 Midnight'"?

When selecting 2AM the following error is returned:
Thu 14 Aug 2008 10:41:48 AM EDT:
Found grammar match
hypothesis #0: 02 (0.9740)
VXI::var_element(name="H" expr = "02")
ReferenceError: AM_PM is not defined line 1
received event: error.semantic.ecmascript:
How can it return such an error if "AM_PM" was returned correctly in <prompt> You chose <value expr="AM_PM"/></prompt>?

Here's the full code:

Code: Select all

 <!-- /////////////////////// 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'">
 <var name="AM_PM" expr="'AM'"/>
<else/>
 <var name="AM_PM" expr="'PM'"/>
 <var 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">   <var name="H" expr="01"/>
<elseif cond = "hour == 2"/>   <var name="H" expr="02"/>
<elseif cond = "hour == 3"/>   <var name="H" expr="03"/>
<elseif cond = "hour == 4"/>   <var name="H" expr="04"/>
<elseif cond = "hour == 5"/>   <var name="H" expr="05"/>
<elseif cond = "hour == 6"/>   <var name="H" expr="06"/>
<elseif cond = "hour == 7"/>   <var name="H" expr="07"/>
<elseif cond = "hour == 8"/>   <var name="H" expr="08"/>
<elseif cond = "hour == 9"/>   <var name="H" expr="09"/>
<elseif cond = "hour == 10"/>  <var name="H" expr="10"/>
<elseif cond = "hour == 11"/>  <var name="H" expr="11"/>
<else/>
 <var name="H" expr="12"/>
</if>

<if cond="H == 12">
<goto next="#NoonOrMidnight"/>
<elseif cond ="AM_PM == PM"/>
<assign name="call_hour" expr="H + 12"/>
<var name="SayH" expr="H + 'AM_PM'"/>
<else/>
<assign name="call_hour" expr="H"/>
<var 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>
Okay, I'll be calling you between <value expr="SayH"/> and <value expr="SayH + 1"/>.
</prompt>
<goto next="#SubmitPatientDATA"/>
</block>
</form>

 <!-- /////////////////////////// SUBMIT ALL DATA ///////////////////////// -->

PS: At one point I had Noon working but not Midnight, and both would fail at "PostVerifyHour" returning the same error as above "ReferenceError: SayH is not defined line 1". How could it pass all the earlier "SayH" variables and save the error for the last one???

Define variables at top of IVR application

Posted: Thu Aug 14, 2008 11:46 am
by support
Hi Chris,

You should define these variables at the top of your IVR application to avoid getting this IVR error:

For IVR example:

Code: Select all

<var name="AM_PM" expr="''"/>
<var name="SayH" expr="''"/>
These should clear up these IVR errors.

Regards,
Plum Support

Posted: Thu Aug 14, 2008 2:43 pm
by Chris
Thank you. That helps.

But at the end when it plays back it fails. In the following code it reads back "One".
So it reads "Okay, I'll be calling you between and 1".
When it should say "Okay, I'll be calling you between 12 Noon and 1 PM".

Code: Select all

<form id="PostVerifyHour">
<block>
<prompt>
Okay, I'll be calling you between <value expr="SayH"/> and <value expr="SayH + 1"/>.
</prompt>
<goto next="#SubmitPatientDATA"/>
</block>
</form>
But at the end when it plays back it fails. In the following it reads back the strings.

Code: Select all

<form id="PostVerifyHour">
<block>
<prompt>
Okay, I'll be calling you between <value expr="'SayH'"/> and <value expr="'SayH + 1'"/>.
</prompt>
<goto next="#SubmitPatientDATA"/>
</block>
</form>
Also, when I choose an hour before 10 AM or PM I get the following error:
Thu 14 Aug 2008 02:45:19 PM EDT:
Found grammar match
hypothesis #0: 08 (0.9630)
VXI::var_element(name="H" expr = "08")
08 is not a legal ECMA-262 octal constant line 1
received event: error.semantic.ecmascript:

Does this mean that I can't use a zero in the hour 00= midnight, 01=OneAM 02=TwoAM etc. ???

I'm using 00=midnight and it's going into the MySQL as "0"

IVR code for user error

Posted: Thu Aug 14, 2008 3:08 pm
by support
Hi Chris,

Try making the following changes to your IVR code. Most of these changes are for your <filled> blocks in your IVR code.

Code: Select all

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

Code: Select all

<filled>
     <if cond = "hour == 1">   <var name="H" expr="01"/>
<elseif cond = "hour == 2"/>   <var name="H" expr="02"/>
<elseif cond = "hour == 3"/>   <var name="H" expr="03"/>
<elseif cond = "hour == 4"/>   <var name="H" expr="04"/>
<elseif cond = "hour == 5"/>   <var name="H" expr="05"/>
<elseif cond = "hour == 6"/>   <var name="H" expr="06"/>
<elseif cond = "hour == 7"/>   <var name="H" expr="07"/>
<elseif cond = "hour == 8"/>   <var name="H" expr="08"/>
<elseif cond = "hour == 9"/>   <var name="H" expr="09"/>
<elseif cond = "hour == 10"/>  <var name="H" expr="10"/>
<elseif cond = "hour == 11"/>  <var name="H" expr="11"/>
<else/>
 <var 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>
As for the problem with "Okay, I'll be calling you between and 1", it will now say, "Okay, I'll be calling you between 1 AM and 1 AM + 1." The reason for this is because you are trying to add the value 1 to a string variable that contains "1 AM".

Regards,
Plum Support

IVR fix for octal error

Posted: Thu Aug 14, 2008 3:14 pm
by support
As for the octal error, you should either remove the leading 0 from your IVR expr (i.e. replace 08 with 8 or 01 with 1) or make it a string by placing single quotes around it (i.e. '08').

Posted: Thu Aug 14, 2008 4:12 pm
by Chris
Okay, then following your logic, this new code should work.
But it doesn't.

I'm still getting "Okay, I'll be calling you between and 1"
The variables have dropped their values.

Code: Select all

<form id="PostVerifyHour">
<block>
<prompt>
Okay, I'll be calling you between <value expr="H"/> and <value expr="H + 1"/> <value expr="AM_PM"/>.
</prompt>
<goto next="#SubmitDATA"/>
</block>
</form>
Also, this may indicate where the problem lies.
The following code works fine.

Code: Select all

 <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>
But when I move "You chose <value expr="AM_PM"/>" into <menu id="VerifyAM_PM">
It does not return any value !

Code: Select all

 <prompt>
 Thank you. 
 </prompt>
 <goto next="#VerifyAM_PM"/>
 </filled>

 </field>
 </form>

 <menu id="VerifyAM_PM">
 <prompt bargein="true" timeout="2s">
You chose <value expr="AM_PM"/>
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>
It looks like the variables are losing their values. Is that so?
Why? And how do we force it to remember?

Clarification of IVR fix for octal error

Posted: Thu Aug 14, 2008 4:28 pm
by support
Hi Chris,

If you're going to make this change in your IVR code, then you need to declare the variable, H:

Code: Select all

<var name="H" expr="''"/>
and make this change in your IVR code:

Code: Select all

<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>
Regards,
Plum Support

Posted: Thu Aug 14, 2008 4:48 pm
by Chris
Yes I already had <var name="H" expr="''"/>
in place with the other vairables.
<var name="AM_PM" expr="''"/>
<var name="H" expr="''"/>
<var name="SayH" expr="''"/>

To be certain I was using the right code,
I did a copy & paste of your code
and it results in giving me just the hour not AM or PM

If I first enter AM, then enter 7
the following code only returns with "7" not AM.

Notice that I've tried it two different ways. Neither works.

Code: Select all

 
 <prompt>
Thank you. You entered <value expr="SayH"/> 
Thank you. You entered <value expr="H"/><value expr="AM_PM"/>
 </prompt>
 <goto next="#Verifyhour"/>