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

Elseif condition not being reached

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
Sparker
Posts: 14
Joined: Tue Jan 27, 2015 10:48 am

Elseif condition not being reached

Post by Sparker »

I am using pre-recorded messages in my test application. That is going very well! However, the part I'm having trouble with--and it seems I've done this before and just cannot seem to get it to work here, is in the form below "SpeakToSubject", fill a field named "speakingTo" with my subject's response (voice and dtmf enabled) and then once filled, evaluate the field value in filled condition to determine where to go next...

As you can see below, I'm trying to do this step by step. If I choose 'Yes', then it works just fine. However if I choose 'No' it does not fall into the "elseif" condition--the call simply disconnects. I'm sure it's something simple that I am doing something missing/doing wrong, but I cannot figure it out.

Any help would be appreciated!
Thanks!

Code: Select all

   
    <form id="Welcome">
        <block>
            <prompt>
                <audio expr="voiceUrl+'<%=gWav.ToString()%>' ">
                    <%=greeting.ToString()%>
                </audio>
            </prompt>             
            <prompt>
                   <sentence><say-as type="name"><%=IVRCall.subName.ToString()%></say-as></sentence>
            </prompt>          
            <goto next="#SpeakToSubject" /> 
        </block>

        </form>
 
 <form id="SpeakToSubject">
        <field name="speakingTo">
            <grammar src="builtin:grammar/boolean" />
            <grammar src="builtin:dtmf/boolean" />
            <prompt>
                <audio expr="yesNoUrl">
                    For Yes, press 1 or Say Yes. For No, press 2 or Say No.                        
                </audio>
            </prompt>
            <filled>
                <if cond="speakingTo==1" >
                     Going on to rest of survey.
                <elseif cond="speakingTo==2" />
                    Need to get right person.
                    <clear namelist="speakingTo" />
                </if>
            </filled>
        </field>
    </form>

Sparker
Posts: 14
Joined: Tue Jan 27, 2015 10:48 am

Re: Elseif condition not being reached

Post by Sparker »

Even though I figured out my problem and am posting it, I do have a question and need clarification on it (see below).

I figured it out what I was doing wrong--among a few other things --just trying to get it to work, I was testing the boolean to return a "2", which I thought with Plum Voice a boolean type DID return a "2" for No or FALSE, it actually is returning a "0".

Can you please clarify this for me? I want my users to be able to use dtmf AND voice. So--what should I test for in my if condition?

Thanks,
Shawntel

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

Re: Elseif condition not being reached

Post by support »

Hi Shawntel,

The boolean type mimics that of a boolean value, so the response will always be 1 for yes (true), and 0 for no (false).

There are a number of ways to implement the boolean grammar for both dtmf and voice, but this is how we would recommend doing so.

The way the <filled> block works is that only if a valid input to match you grammar is matched, then the <filled> block will be entered. For the voice grammar, this is a spoken yes or no, and for the dtmf gramamr, this is a keypress of 1 or 2. Therefore, since we know once the caller enters the <filled> block, that they have entered one of those two values. The simplest logic for handling this in the filled block would be as such:

Code: Select all

<if cond="speakingTo" >
  Going on to rest of survey.
<else/>
  Need to get right person.
  <clear namelist="speakingTo" />
</if>
This way, when the caller enters yes or 1, the value of the "speakingTo" variable will be true, and therefore this block will be executed. Otherwise, we can safely assume that the caller has entered false (or 2), since they are in the <filled> block and did not enter yes or 1, and the <else> condition will be executed.

There's one additional tip we'd like to mention, and that is regarding built-in grammars.
Instead of specifying the two boolean grammars individually, you can include the built in type on the <field> tag itself, like such:

Code: Select all

 <form id="SpeakToSubject">
        <field name="speakingTo" type="boolean">
            <prompt>
                For Yes, press 1 or Say Yes. For No, press 2 or Say No.                        
            </prompt>
            <filled>
                <if cond="speakingTo" >
                     Going on to rest of survey.
                <else/>
                    Need to get right person.
                    <clear namelist="speakingTo" />
                </if>
            </filled>
        </field>
</form>
This is just a shorthand method for the same two grammar you had set previously with the <grammar> tag.

More details on the built-in grammars can be found here:
http://www.plumvoice.com/docs/dev/devel ... n_grammars

Please let us know if you have any additional question.

Regards,
Plum Support

Post Reply