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

Problems with </elseif> & </if>

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

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

IVR fix for octal error

Post by support »

Hi Chris,

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>
Regards,
Plum Support
Last edited by support on Wed Feb 17, 2010 4:35 pm, edited 4 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Thanks a big bunch.
So why was it working for you and not for me?
I don't really see the difference.

Also, it's beginning to skip prompts again!!!
Thanks,
Chris

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Why am I having so many problems with variables?
The variables work well in another document which uses the same root as this one.
But with this code I just get:
ReferenceError: product_id is not defined line 1
received event: error.semantic.ecmascript:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="e00_OpenDB_Globals.php">
name="robots" content="noindex,nofollow"/>
<property name="caching" value="safe"/>
 <property name="interdigittimeout" value="3s"/>
<property name="sensitivity" value="0.3"/>
<property name="confidencelevel" value="0.3"/>
<property name="voicegender" value="male"/> 
 

<var name="program_name" expr=" '<? echo ($Program_row[0]) ?>' " />
<assign name="application.ProgramName" expr="program_name"/>

<var name="product_id" expr=" '<? echo ($Product_row[0]) ?>' " />
<assign name="application.ProductName" expr="product_id"/>


<form id="Bye">
<block>
Okay, I've got all your information committed to memory.
<!-- You can expect me to start calling you on the schedule you requested. -->

I will be calling you periodically to help you get the most value from <value expr="product_id"/>. 
You can expect me to start calling you on the day you chose. 

If you ever want to be removed from the program, 
or make changes to your <value expr="program_name"/> Account, call me back at 1-800-000-0000. 
Just remember to make a note of your PIN number, 
so you don't forget it. 
Your PIN number is [PIN#]. 
You will need it to access your account if you ever want to make changes. 
Thanks for joining. 

<goto next="e99_Goodbye.vxml"/> 
</block>
</form>
</vxml>
Thanks,
Chris

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

IVR variables need to be declared first

Post by support »

Hi Chris,

In general, variables need to be declared first before you assign them with expressions.

So, you should replace these lines of your IVR code:

Code: Select all

<var name="program_name" expr=" '<? echo ($Program_row[0]) ?>' " />
<assign name="application.ProgramName" expr="program_name"/>

<var name="product_id" expr=" '<? echo ($Product_row[0]) ?>' " />
<assign name="application.ProductName" expr="product_id"/> 
with this IVR code:

Code: Select all

<var name="program_name" expr="''"/>
<var name="program_id" expr="''"/>
<var name="application.ProgramName" expr="''"/>
<var name="application.ProductName" expr="''"/>

<assign name="program_name" expr=" '<? echo ($Program_row[0]) ?>' " />
<assign name="application.ProgramName" expr="program_name"/>

<assign name="product_id" expr=" '<? echo ($Product_row[0]) ?>' " />
<assign name="application.ProductName" expr="product_id"/> 
Regards,
Plum Support
Last edited by support on Wed Feb 17, 2010 4:36 pm, edited 3 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Thank you. I will try your solution.
Does every document need to declare the variables, or just the Root document?

I have another question, and I'll try to make it simple and clear.


Let's say there are 4 documents to my application:

Root.php
CollectUserData.vxml
UpLoadUserDataToMySQL.php
ConfirmUserData.vxml


CollectUserData.vxml not only accesses variables from the Root.php,
but it also collects data from the User and creates additional variables,
the value of which are sent to UpLoadUserDataToMySQL.php for db inclusion.

The last document in line, ConfirmUserData.vxml, must play back variables from both Root.php and CollectUserData.vxml

Can this be done with the interruption of UpLoadUserDataToMySQL.php or does the interruption break the link?
Thanks,
Chris

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

IVR issue needs further info to be resolved

Post by support »

Hi Chris,

Yes, it is standard IVR practice to define the variables in each of your documents.

As for your question, can you clarify what you mean by "interruption"?

As long as you reference the root document across all your documents, none of your variables will be lost when you do page transitions.

Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:22 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

By interruption I mean that one document,CollectUserData.vxml, calls up another,UpLoadUserDataToMySQL.php, that does not refer to the root document.
Once the SUBMIT command from within CollectUserData.vxml takes us to UpLoadUserDataToMySQL.php
CollectUserData.vxml is no longer in use, and as I understand it, will lose the values in the variables.
UpLoadUserDataToMySQL.php is in a different directory and is itself a different document.

Then it points back to ConfirmUserData.vxml.

Would ConfirmUserData.vxml have to use CollectUserData.vxml as its root instead of Root.php?

When do the variables forget their values?
Thanks,
Chris

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

Information for root documents within IVR system

Post by support »

Hi Chris,

No, all your documents must refer to Root.php so that the context of the variables do not become lost between page transitions.

Since UpLoadUserDataToMySQL.php is pointing back to ConfirmUserData.vxml anyways, you should just reference the root document, Root.php, in it.

For more information on root documents within the IVR system, see here: www.plumvoice.com/docs/dev/developer_re ... otdocument

Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:23 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Okay,
Then how will ConfirmUserData.vxml
know the value of the variables that are created in CollectUserData.vxml which is above the Root.php ?

After all the variables that are created in CollectUserData.vxml are not contained within Root.php.
Thanks,
Chris

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

IVR application and global variables

Post by support »

Declare the variables in Root.php, then assign them in CollectUserData.vxml. Variables that are going to be used throughout your entire IVR application should be declared as global variables anyways so you can do this by declaring them in your root document, Root.php.

Regards,
Plum Support
Last edited by support on Sat Dec 26, 2009 8:02 pm, edited 1 time in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

You missed my point.
Variables that are created in a document above the ROOT
Can't get into the ROOT document, can they?
Thanks,
Chris

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

Edit IVR code so root doc has nothing above it

Post by support »

Hi Chris,

Root documents are generally used for storing global variables so that all leaf documents can make reference to them and no document comes before it, thus making it the root. You should consider editing your IVR code around so that you root document has nothing that comes above it and so that you can access the variables from your root document in any documents that follow.

Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:24 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

So, if I follow what you are saying,
I would have to make the entire application a ROOT doucment.
That's not realistic.

Currently the ROOT provides basic level data that is used in the LEAF document
which also collects additional data.

Data from both the ROOT and new data collected by the LEAF are used in yet another LEAF after data is submitted to the db.

----------------------

Let me say this yet another way:
ROOT PROVIDES "Hello, our group's name is Plum."

LEAF #1 PROVIDES: "What's your name?"
LEAF #1 COLLECTS: "Chris"

SUBMIT PHP INSERTS: "Chris" into the db.

LEAF #2 RETURNS: "Thank you Chris for joining Plum."
Thanks,
Chris

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

Suggestion for IVR format

Post by support »

No, here's the format I'm suggesting:

Root->Leaf1->Leaf2-> etc...

All leaf documents can reference variables from the root document.

From your recent post, you mentioned that you have a document above the root document:
You missed my point.
Variables that are created in a document above the ROOT
Can't get into the ROOT document, can they?
which would defeat the purpose of the root document.

So from your example, you can define the variable that's going to collect "Chris" in your root document:

Code: Select all

<var name="collectname" expr="''"/>
and then in your leaf 1 document, you could do something like this with your IVR code:

Code: Select all

  <field name="username">
     <grammar>
        ...
     </grammar>
    <prompt>
      Please say your name.
    </prompt>
    <filled>
      <prompt>
        You said <value expr="username"/>.
      </prompt>
      <assign name="collectname" expr="username"/>
    </filled>
  </field>
Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:25 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

So, are you telling me
that as long as I declare a variable in the ROOT,
I can fill it with a value collected from any LEAF document?

Therefore my ROOT document would start off
with a bunch of variables with no values to them,
and the data collected by LEAF documents
would populate the variables in that ROOT doc.

Is that right?
Thanks,
Chris

Post Reply