Page 1 of 1

How to submit data when caller hangs up

Posted: Mon Mar 19, 2012 2:28 pm
by tony
Hi,

I have a index.vxml file like the one showed below which contains questions whose answers are submitted to a saveResponses.php file at the end of the survey; however, some callers may hang up before they get to the end and I need to save their answers when they hang up; I am using <catch event="connection.disconnect"> but iit seems it is not executing <submit> can you please tell how to correctly submit variables to be saved when callers hang up.

Tony

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE vxml SYSTEM "http://plumvoiceportals.com/vxml-260.dtd">
<vxml xml:lang="es-MX" version="2.0" >

<noinput>
  <prompt>
    <speak xml:lang="es">
      Lo siento, no pude oírle.
    </speak>
  </prompt>
  <reprompt/>
</noinput>

<nomatch>
  <prompt>
    <speak xml:lang="es">
      Lo siento, no le entiendo.
    </speak>
  </prompt>
  <reprompt/>
</nomatch>

<property name="sensitivity" value="0.0"/>

<var name="qCustomerId" expr="'ID-GOES-HERE'"/>
<var name="qb1_Contractor" expr="0"/>
<var name="qb2_Change" expr="0"/>
<var name="qb2a_Description" expr="0"/>
<var name="q3TrabajoConstruccion" expr="0"/>

<form id="wfvt_survey">

  <subdialog name="qb1_dlog" src="yesno.vxml"> 
    <param name="confirm_prompt" expr="some question'"/>
    <filled>
       <assign name="qb1_Contractor" expr="qb1_dlog.response"/>
    </filled>
</subdialog>

  <subdialog name="qb2_dlog" src="yesno.vxml">
    <param name="confirm_prompt" expr="'some question'"/>
    <filled>
       <assign name="qb2_Change" expr="qb2_dlog.response"/>
    </filled>
</subdialog>

<subdialog name="qb2a_Description_dlog" src="audio.vxml" cond="qb2_Change == '1'">
   <param name="confirm_prompt" 
       expr="'some description question.'"/> 
    <filled>
       <assign name="qb2a_Description" expr="qb2a_Description_dlog.response"/>
    </filled>
  </subdialog>

<subdialog name="q3_dlog" src="yesno.vxml"> 
    <param name="confirm_prompt" expr="'¿Trabajó en construcción.?'"/> 
    <filled>
       <assign name="q3TrabajoConstruccion" expr="q3_dlog.response"/>
       <if cond="q3TrabajoConstruccion=='1'">
    </filled>
</subdialog>
    
<catch event="connection.disconnect.hangup">
<submit next="saveResponses.php" namelist="qCustomerId , fullname , time_of_call , qb1_Contractor , qb2_Change , qb2a_Description , q3TrabajoConstruccion" method="post" enctype="multipart/form-data"/>  
             <exit/>
</catch>

</form>

</vxml>

Re: How to submit data when caller hangs up

Posted: Tue Mar 20, 2012 5:32 pm
by support
Hi Tony,

The saveResponses.php will need to return valid VXML as well as not queuing any audio or prompts. The script could be similar to:

Code: Select all

<?php
header("Content-type: text/xml");

if (isset($_POST))
  $output = var_export($_POST, true);

$handle = fopen("/var/tmp/result_post.txt", "w");
fwrite($handle, $output);
fclose($handle);

echo "<?xml version=\"1.0\"?>";
?>

<vxml version="2.0">
  <form>
    <block>
      <exit/>
    </block>
  </form>
</vxml>
This code takes the POST values from the previous script and writes the values to disk. When viewing result_post.txt we see the values:

Code: Select all

array (
  'fullname' => 'fullname',
  'q3TrabajoConstruccion' => 'q3TrabajoConstruccion',
  'qCustomerId' => 'qCustomerId',
  'qb1_Contractor' => 'qb1_Contractor',
  'qb2_Change' => 'qb2_Change',
  'qb2a_Description' => 'qb2a_Description',
  'time_of_call' => 'time_of_call',
)
We see this same data is set within the previous script. We simplified our version:

Code: Select all

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

<vxml version="2.0">
  <var name="qCustomerId" expr="'qCustomerId'"/>
  <var name="fullname" expr="'fullname'"/>
  <var name="time_of_call" expr="'time_of_call'"/>
  <var name="qb1_Contractor" expr="'qb1_Contractor'"/>
  <var name="qb2_Change" expr="'qb2_Change'"/>
  <var name="qb2a_Description" expr="'qb2a_Description'"/>
  <var name="q3TrabajoConstruccion" expr="'q3TrabajoConstruccion'"/>

  <form>
    <field name="test" type="digits">
      <prompt>
	Hang up now.
      </prompt>
    </field>
  
    <catch event="connection.disconnect.hangup">
      <submit next="saveResponses.php" namelist="qCustomerId fullname time_of_call qb1_Contractor qb2_Change qb2a_Description q3TrabajoConstruccion" method="post" enctype="multipart/form-data"/>
    </catch>
  </form>
</vxml>
Hope this helps.

Regards,
Plum Support

Re: How to submit data when caller hangs up

Posted: Fri Mar 30, 2012 3:53 pm
by tony
Hi,

Thank you very much! I just figured it out.

Tony