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

Voice & DTMF input/Setting certain conditions/Capturing us

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
jperez1107
Posts: 3
Joined: Wed Apr 14, 2010 5:40 pm

Voice & DTMF input/Setting certain conditions/Capturing us

Post by jperez1107 »

While I have some valuable and useful references at my disposal, I’m fairly new to VXML and I have a few things I need help with.

I’m putting together a survey to be accessed via telephone using VXML. We would like the user data to be captured in a document to be analyzed later. We’re not using Plum Survey, but rather building the survey from scratch.

1. My first question is regarding how to set it up so that the user can interact with the system using both voice and dtmf . I’ve tried using both builtin IVR and inline IVR methods but I’m not sure if I’m doing it correctly, since I’m unclear about what the default JSGF format allows for. For instance, I know I can use the following:

Code: Select all

<grammar type=”application/x-jsgf” mode=”dtmf”> 
                                          1 | 2
                                    </grammar>

for DTMF, and

Code: Select all

<grammar type=”application/x-jsgf” mode=”voice”> 
                                         one | two
                                    </grammar>
for each one respectively, but is it valid to use

Code: Select all

<grammar type=”application/x-jsgf” mode=”dtmf voice”>
                                            1 | 2 |one |two
                                    </grammar>
or some derivation thereof to be able to combine both?

2. My second question is this: there are certain questions in the later part of the survey that should be asked only depending on what they answered in two or more earlier questions. For example, Question 7 about “what position did you play last night” would only be asked if you answered “baseball” for Question 1, “which of the following sports do you play?” AND you answered “yes” to Question 6, “did you play more than three innings last night?” What would be the best way to address this kind of question? Is there was a tag similar to the <if> tag that would allow me to input multiple conditions that must be met for a question to be asked?

3. Finally, I’m working under the assumption that user input contained within a <field> tag is going to be captured as long as I use the <submit> tag to specify a particular document in my server to capture the user data into. Is this a correct assumption?


Thank you for your time!

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

Re: Voice & DTMF input/Setting certain conditions/Capturing

Post by support »

Hi,

About Question 1, yes, you can do a combination of both dtmf and voice for your <grammar> tag in your IVR code. The IVR code example below demonstrates how you can use DTMF and voice for your grammar.

example1.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<field name="myfield">
<grammar type="application/x-jsgf" mode="dtmf voice">
1 | 2
</grammar>
<prompt>
Please say one or two.
</prompt>
<filled>
You entered <value expr="myfield"/>.
</filled>
</field>
</form>
</vxml>
About Question 2, yes, you can use the <if> tag with specific conditions in it so that you can ask specific questions for your IVR survey. The IVR example below demonstrates how you can assign values to global variables and then use them in an <if> tag condition:

example2.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">

<var name="var1" expr=""/>
<var name="var2" expr=""/>
<var name="var3" expr=""/>

<form>
<field name="myfield1">
<grammar type="application/x-jsgf" mode="dtmf voice">
1 | 2
</grammar>
<prompt>
Please say one or two.
</prompt>
<filled>
<prompt>
You entered <value expr="myfield1"/>.
</prompt>
<assign name="var1" expr="myfield1"/>
</filled>
</field>

<field name="myfield2">
<grammar type="application/x-jsgf" mode="dtmf voice">
3 | 4
</grammar>
<prompt>
Please say three or four.
</prompt>
<filled>
<prompt>
You entered <value expr="myfield2"/>.
</prompt>
<assign name="var2" expr="myfield2"/>
<if cond="var1==1 && var2==3">
<goto next="#finish1"/>
<else/>
<goto next="#finish2"/>
</if>
</filled>
</field>
</form>

<form id="finish1">
<block>
<prompt>
1 and 3. Good bye.
</prompt>
</block>
</form>

<form id="finish2">
<block>
<prompt>
Not 1 and 3. Good bye.
</prompt>
</block>
</form>

</vxml>


About Question 3, yes, user input contained within a <field> tag is going to be captured if you use a <submit> tag to specify a particular document on your web server. The IVR example below demonstrates this:

example3.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<field name="myfield">
<grammar type="application/x-jsgf" mode="dtmf voice">
1 | 2
</grammar>
<prompt>
Please say one or two.
</prompt>
<filled>
You entered <value expr="myfield"/>.
<submit next="submit.php" method="post" namelist="myfield"/>
</filled>
</field>
</form>
</vxml>
submit.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");

$myfield = $_POST[myfield];
?>

<vxml version="2.0">
  <form>
    <block>
      <prompt>
        We got your variable. It is <?php echo($myfield)?>.
      </prompt>
    </block>
  </form>
</vxml>
Hope this helps.

Regards,
Plum Support

Post Reply