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

read a list of elements and foreach to do save, do delete ..

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
mariuka_t@yahoo.com
Posts: 3
Joined: Thu Mar 05, 2009 4:34 am

read a list of elements and foreach to do save, do delete ..

Post by mariuka_t@yahoo.com »

I am having some difficulties when I try to read a list of elements and for each element to do save, or delete (customer's choice) and move to the next element in the list.
I am having some difficulties when I try to read a list of elements that comes from the application and depends on the logged user.


<?xml version="1.0" encoding="UTF-8" ?>
<vxml version="2.0">

<form >
<script src="http://www.bissoft.ro/HomeHealth/WebIVR/IVR.js" maxage="5000" maxstale="5000"/>

<block>
<var name="report"/>
<prompt>"Please report the status of the following items"</prompt>
</block>

<block>
<prompt> <break time="500ms"/>
<foreach item="i" array="ItemReports()">
value <value expr="i"/> <break/>
<assign name="report" expr="i" />
<goto next="#item"/>
</foreach>
</prompt>
<goto next="#item"/>
</block>

</form>

<form id="allDone">
<block><prompt>There is nothing left to do.</prompt><disconnect/></block>
</form>


<menu id="item">
<prompt>
Press 1 if complete
Press 2 if refused
Press 3 if patient not able
Press 4 if already done
Press 5 if not applicable
Press 6 if admin change
</prompt>
<choice dtmf="1" next="#itemComplete">
complete</choice>
<choice dtmf="2" next="#itemRefused">
refused</choice>
<choice dtmf="3" next="#itemPatientNotAble">
patient not able</choice>
<choice dtmf="4" next="#itemDone">
already done</choice>
<choice dtmf="5" next="#itemNotAplicable">
not applicable</choice>
<choice dtmf="6" next="#itemAdminChange">
admin change</choice>
</menu>

<form id="itemComplete">
<var name="method" expr="'itemComplete'" />
<block>
<goto next="#status"/>
</block>
<block>
<submit namelist="method report" next="http://www.bissoft.ro/HomeHealth/WebIVR/PlumIVR.aspx"/>
</block>
</form>

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

IVR code to read a list of elements

Post by support »

Hi,

Here is an IVR code example that should help you achieve this. Please note how an array is implemented through the IVR tags, <value> and <if> in elementcounter.php:

test.js

Code: Select all

function ItemReports() {
   return ['item report 1','item report 2']; 
}
elementcounter.php

Code: Select all

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

<property name="inputmodes" value="dtmf"/>

<var name="arraypos" expr="0"/>
<script src="test.js" maxage="0" maxstale="0"/>

<var name="arr" expr="ItemReports()"/>

<var name="result" expr="''"/>

<form id="form1">

<block>
<prompt>
<value expr="arr[arraypos]"/>
</prompt>
<if cond="++arraypos < arr.length+1">
  <goto next="#item"/>
</if>
<goto next="#form2"/>
</block>
</form>

<menu id="item">
<prompt>
Press 1 if complete
Press 2 if refused
Press 3 if patient not able
Press 4 if already done
Press 5 if not applicable
Press 6 if admin change
</prompt>
<choice dtmf="1" next="#itemComplete">
complete</choice>
<choice dtmf="2" next="#itemRefused">
refused</choice>
<choice dtmf="3" next="#itemPatientNotAble">
patient not able</choice>
<choice dtmf="4" next="#itemDone">
already done</choice>
<choice dtmf="5" next="#itemNotAplicable">
not applicable</choice>
<choice dtmf="6" next="#itemAdminChange">
admin change</choice>
</menu> 

<form id="itemComplete">
<block>
<prompt>
Marked as complete.
</prompt>
<goto next="#form1"/>
</block>
</form>

<form id="form2">
  <block>
    <prompt>
      All done.
    </prompt>
  </block>
</form>

</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Wed Feb 24, 2010 2:28 pm, edited 5 times in total.

mariuka_t@yahoo.com
Posts: 3
Joined: Thu Mar 05, 2009 4:34 am

Post by mariuka_t@yahoo.com »

Uhm, that's not a solution. Think I didn't explain right what I want to be happening in the application.

I have a list on Plum Voice. I get the first element, and I send it to my application and I use it to connect with my database.
After I do this, I want to go back to the list and I need to do the same for the following elements from the list.

Can I use XSL files to do that ?

Thank You!

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

Clarification of IVR code to read a list of elements

Post by support »

Hi,

You can use a subdialog within your IVR script to do this.

For IVR example:

test.js

Code: Select all

function ItemReports() {
   return ['item report 1','item report 2'];
} 
elementcounter.php

Code: Select all

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

<property name="inputmodes" value="dtmf"/>

<var name="arraypos" expr="0"/>
<script src="test.js" maxage="0" maxstale="0"/>

<var name="arr" expr="ItemReports()"/>

<var name="result" expr="''"/>

<form>
<block>
<var name="report"/>
<prompt>"Please report the status of the following items"</prompt>
<goto next="#form1"/>
</block>
</form>

<form id="form1">

<block>
<prompt>
<value expr="arr[arraypos]"/>
</prompt>
<if cond="++arraypos < arr.length+1">
  <assign name="report" expr="arraypos" />
  <goto next="#item"/>
</if>
<goto next="#form2"/>
</block>
</form>

<menu id="item">
<prompt>
Press 1 if complete
Press 2 if refused
Press 3 if patient not able
Press 4 if already done
Press 5 if not applicable
Press 6 if admin change
</prompt>
<choice dtmf="1" next="#itemComplete">
complete</choice>
<choice dtmf="2" next="#itemRefused">
refused</choice>
<choice dtmf="3" next="#itemPatientNotAble">
patient not able</choice>
<choice dtmf="4" next="#itemDone">
already done</choice>
<choice dtmf="5" next="#itemNotAplicable">
not applicable</choice>
<choice dtmf="6" next="#itemAdminChange">
admin change</choice>
</menu> 

<form id="itemComplete">
<var name="method" expr="'itemComplete'"/> 
<subdialog namelist="method report" method="post" src="subdialog.php"/>
<block>
<prompt>
Marked as complete.
</prompt>
<goto next="#form1"/>
</block>
</form>

<form id="form2">
  <block>
    <prompt>
      All done.
    </prompt>
  </block>
</form>

</vxml>
subdialog.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
$method = $_POST['method'];
$report = $_POST['report'];

//add code here for submitting data to your database;
?>
<vxml version="2.0">
<form>
	<block>
		<prompt>
                  The method was <value expr="'<?php echo($method)?>'"/>
                </prompt>
		<prompt>
                  The report was <value expr="'<?php echo($report)?>'"/>
                </prompt>
		<return/>
	</block>
</form>
</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Tue Feb 16, 2010 6:09 pm, edited 3 times in total.

mariuka_t@yahoo.com
Posts: 3
Joined: Thu Mar 05, 2009 4:34 am

Post by mariuka_t@yahoo.com »

Thank you very much. I managed to make it work with your help.

Thank You!

Post Reply