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

Submit to offsite url after transfer

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
Vandy1Fan
Posts: 5
Joined: Thu Aug 21, 2014 2:45 pm

Submit to offsite url after transfer

Post by Vandy1Fan »

I'm trying to setup a way to capture the transfer duration and return it to my server using a url.

It does not appear that the filled or catch is called as my log on my web server shows nothing.
When I hang up from the transfer, the call ends and no result is sent.
The xxx= value tells me which procedure is called.
It also appears that the name value pair transduration=some value does not get passed to the form data on my server. Only the standard name value pairs are received.

Here is a portion of the vxml.

<form id="transferid2">
<var name="transduration"/>
<transfer name="my_transfer" bridge="true" dest="16157793921">
<filled>
<assign name="transduration" expr="my_transfer$.duration"/>
<submit next="http://myserver.com/ivrresult?IVRID=943mc=2xxx=9" namelist="my_transfer transduration" method="post" enctype="application/x-www-form-urlencoded"/>
</filled>
<catch event="connection.disconnect">
<submit next="http://myserver.com/ivrresult?IVRID=943mc=2xxx=8" namelist="my_transfer transduration" method="post" enctype="application/x-www-form-urlencoded"/>
</catch>
</transfer>
<catch event="connection.disconnect">
<submit next="http://myserver.com/ivrresult?IVRID=943mc=2xxx=8" namelist="my_transfer transduration" method="post" enctype="application/x-www-form-urlencoded"/>
</catch>
<catch event="noinput" count="1">
<reprompt/>
</catch>
<catch event="noinput" count="2">
<disconnect/>
</catch>
<catch event="nomatch" count="1">
<reprompt/>
</catch>
<catch event="nomatch" count="10">
<disconnect/>
</catch>
</form>

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

Re: Submit to offsite url after transfer

Post by support »

Hi,

From your code, "transduration" doesn't get filled if the caller hangs up (triggers event, "connection.disconnect").

You can using the following sample code to capture the transfer duration of a call:

transferduration.php:

Code: Select all

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

<var name="client_phone_num" expr="session.telephone.ani"/>

<form id="transfer">
<var name="transduration"/>
  <transfer name="my_transfer" dest="1XXXXXXXXXX" bridge="true">
    <filled>
      <if cond="my_transfer == 'far_end_disconnect'">
        <throw event="farend"/>
      </if>
    </filled>
  </transfer>

  <catch event="connection.disconnect.hangup farend">
    <assign name="transduration" expr="my_transfer$.duration"/>
    <submit next="store_information.php" namelist="client_phone_num transduration" method="post" enctype="multipart/form-data"/>
  </catch>
</form>
</vxml>
store_information.php

Code: Select all

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

$File = "storeresults.txt";
$Handle = fopen($File, 'a+');
$Date = date("r");
$UserNum = $_POST[client_phone_num];
$Transduration = $_POST[transduration];
$Data = "$Date $UserNum $Transduration\n";
fwrite($Handle, $Data);
fclose($Handle);
?>

<vxml version="2.0">
  <form>
    <block>
      <exit/>
    </block>
  </form>
</vxml>
From this code, the transfer duration would be stored whether the caller hangs up first or the person being called hangs up first.

Regards,
Plum Support

Vandy1Fan
Posts: 5
Joined: Thu Aug 21, 2014 2:45 pm

Re: Submit to offsite url after transfer

Post by Vandy1Fan »

Here is part of the issue that I am having.
When the user presses the 2 to transfer, it does a submit back to our server and then goes to the transfer form.
The transfer is performed and once the transfer is ended, I need it to do a 2nd submit back to our web site with the transfer duration.
However, the second submit never occurs.
If I remove the first submit and handle it in a <filled> inside the transfer, the transfer never happens, but the submit occurs.

Here is the entire script - Note the bold submit. This never gets called.

<vxml version="2.0">
<property name="inputmodes" value="dtmf voice"/>
<property name="sensitivity" value="0.4"/>
<property name="confidencelevel" value="0.99"/>
<property name="bargein" value="false"/>
<form id="mainmenu">
<field name="menuchoice">
<grammar type="application/x-jsgf" mode="dtmf voice"> one|1|nine|9|two|2 </grammar>
<prompt bargein="true" timeout="5s" xml:lang="en-uk">
<voice name="Charles"> This is a test message. Press 1 to confirm, 2 to transfer or press 9 to repeat.</voice>
</prompt>
<filled>
<if cond="menuchoice=='1'">
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Thank you for confirming. Goodbye.</voice>
</prompt>
<submit next="http://75.151.51.219:82/ivrresult?IVRID=943mc=1" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<elseif cond="menuchoice=='one'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Thank you for confirming. Goodbye.</voice>
</prompt>
<submit next="http://mysite.com/ivrresult?IVRID=943mc=1" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<elseif cond="menuchoice=='9'"/>
<goto next="#mainmenu"/>
<elseif cond="menuchoice=='nine'"/>
<goto next="#mainmenu"/>
<elseif cond="menuchoice=='2'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Transferring now, please hold.</voice>
</prompt>
<prompt/>
<submit next="http://mysite.com/ivrresult?IVRID=943mc ... 6157793921" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<goto next="#transferid2"/>
<elseif cond="menuchoice=='two'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Transferring now, please hold.</voice>
</prompt>
<prompt/>
<submit next="http://mysite.com/ivrresult?IVRID=943mc ... 6157793921" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<goto next="#transferid2"/>
<else/>
<prompt/>
<clear namelist="menuchoice"/>
</if>
</filled>
</field>
</form>
<form id="transferid2">
<transfer name="my_transfer" bridge="true" dest="tel:+016157793921">
<filled>
<var name="transduration" expr="my_transfer$.duration"/>
<submit next="http://mysite.com/ivrresult?IVRID=943mc=2xxx=7" namelist="transduration" method="post" enctype="multipart/form-data"/>
</filled>
<catch event="connection.disconnect.hangup">
<submit next="http://mysite.com/ivrresult?IVRID=943mc=2xxx=0" namelist="transduration" method="post" enctype="multipart/form-data"/>
</catch>
</transfer>
<catch event="connection.disconnect.hangup">
<submit next="http://mysite.com/ivrresult?IVRID=943mc=2xxx=0" namelist="transduration" method="post" enctype="multipart/form-data"/>
</catch>
<catch event="noinput" count="1">
<reprompt/>
</catch>
<catch event="noinput" count="2">
<disconnect/>
</catch>
<catch event="nomatch" count="1">
<reprompt/>
</catch>
<catch event="nomatch" count="10">
<disconnect/>
</catch>
</form>
</vxml>

Vandy1Fan
Posts: 5
Joined: Thu Aug 21, 2014 2:45 pm

Re: Submit to offsite url after transfer

Post by Vandy1Fan »

Here is the last part of the log. You can see the initial submit (mc=2) this was the key pressed.
You can see the transfer connected.
It gets the hangup but does not call the submit.



Fri 22 Aug 2014 11:35:07 AM EDT:
Fetching Document: http://myserver.com/ivrresult?IVRID=943 ... 6157793921
DocumentParser::FetchDocument(http://myserver.com/ivrresult?IVRID=943 ... 6157793921)
Posted form data is URL encoded
Attempting to fetch http://myserver.com/ivrresult?IVRID=943 ... 6157793921
Click here to view saved VoiceXML script
Entering form = '$_internalName_1444096' form item = '$_internalName_1444097'
VXI::queue_prompts()
Bridge Transfer: 16157793921

Fri 22 Aug 2014 11:35:20 AM EDT:
Transfer Connected

Fri 22 Aug 2014 11:35:29 AM EDT:
received event: connection.disconnect.hangup:
VXI::exit_element()
Call End Event
Ending session
Ending Session On Channel 83

Vandy1Fan
Posts: 5
Joined: Thu Aug 21, 2014 2:45 pm

Re: Submit to offsite url after transfer

Post by Vandy1Fan »

I tried your way as well and I get the same result.

Here is the script. This is a HUGE issue for one of my customers as they want to be able to charge differently for transfer times.


<vxml version="2.0">
<property name="inputmodes" value="dtmf voice"/>
<property name="sensitivity" value="0.4"/>
<property name="confidencelevel" value="0.99"/>
<property name="bargein" value="false"/>
<form id="mainmenu">
<field name="menuchoice">
<grammar type="application/x-jsgf" mode="dtmf voice"> one|1|nine|9|two|2 </grammar>
<prompt bargein="true" timeout="5s" xml:lang="en-uk">
<voice name="Charles"> This is a test message. Press 1 to confirm, 2 to transfer or press 9 to repeat.</voice>
</prompt>
<filled>
<if cond="menuchoice=='1'">
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Thank you for confirming. Goodbye.</voice>
</prompt>
<submit next="http://75.151.51.219:82/ivrresult?IVRID=943mc=1" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<elseif cond="menuchoice=='one'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Thank you for confirming. Goodbye.</voice>
</prompt>
<submit next="http://75.151.51.219:82/ivrresult?IVRID=943mc=1" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<elseif cond="menuchoice=='9'"/>
<goto next="#mainmenu"/>
<elseif cond="menuchoice=='nine'"/>
<goto next="#mainmenu"/>
<elseif cond="menuchoice=='2'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Transferring now, please hold.</voice>
</prompt>
<prompt/>
<submit next="http://75.151.51.219:82/ivrresult?IVRID ... 6157793921" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<goto next="#transferid2"/>
<elseif cond="menuchoice=='two'"/>
<prompt timeout="5s" xml:lang="en-uk">
<voice name="Charles"> Transferring now, please hold.</voice>
</prompt>
<prompt/>
<submit next="http://75.151.51.219:82/ivrresult?IVRID ... 6157793921" namelist="menuchoice" method="post" enctype="application/x-www-form-urlencoded"/>
<goto next="#transferid2"/>
<else/>
<prompt/>
<clear namelist="menuchoice"/>
</if>
</filled>
</field>
</form>
<form id="transferid2">
<var name="transduration"/>
<transfer name="my_transfer" bridge="true" dest="tel:+016157793921">
<filled>
<if cond="my_transfer == 'far_end_disconnect'">
<throw event="farend"/>
</if>
</filled>
</transfer>
<catch event="connection.disconnect.hangup farend">
<assign name="transduration" expr="my_transfer$.duration"/>
<submit next="http://75.151.51.219:82/ivrresult?IVRID=943mc=" namelist="transduration" method="post" enctype="multipart/form-data"/>
</catch>
<catch event="connection.disconnect.hangup">
<submit next="http://75.151.51.219:82/ivrresult?IVRID=943mc=2xxx=0" namelist="transduration" method="post" enctype="multipart/form-data"/>
</catch>
<catch event="noinput" count="1">
<reprompt/>
</catch>
<catch event="noinput" count="2">
<disconnect/>
</catch>
<catch event="nomatch" count="1">
<reprompt/>
</catch>
<catch event="nomatch" count="10">
<disconnect/>
</catch>
</form>
</vxml>

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

Re: Submit to offsite url after transfer

Post by support »

Hi,

Please note that when you use the <submit> tag, it will trigger a page transition, so your script would never reach the "transferid2" form of your script.

Below is some sample code you can reference for assistance:

main.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form id="mainmenu"> 
<field name="menuchoice">
  <property name="inputmodes" value="dtmf"/>
  <grammar type="application/x-jsgf">
    1|2|9
  </grammar>
  <prompt> 
    Hello, this is a test message. Press 1 to confirm, 2 to cancel, or 9 to repeat. 
  </prompt>  
  <filled>
    <if cond="menuchoice=='1'"> 
      <prompt> 
        Thank you, you pressed 1 to confirm. Goodbye.
      </prompt>  
    <elseif cond="menuchoice=='2'" /> 
      <prompt> 
        Thank you.
      </prompt>
      <submit next="transferduration.php" namelist="menuchoice" method="post" enctype="multipart/form-data"/>
    <else/>
      <clear namelist="menuchoice"/>
    </if> 
  </filled>
</field>
</form>
</vxml>
transferduration.php:

Code: Select all

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

<var name="userchoice" expr="'<?php echo($userchoice)?>'"/>
<var name="usernum" expr="session.telephone.ani"/>

<form id="transfer">

<var name="transduration"/>

  <block>
    <prompt>
     You pressed <value expr="userchoice"/>. Please hold while we transfer you.
    </prompt>
  </block>
    
  <transfer name="my_transfer" dest="1XXXXXXXXXX" bridge="true">
    <filled>
      <if cond="my_transfer == 'far_end_disconnect'">
        <throw event="farend"/>
      </if>
    </filled>
  </transfer>

  <catch event="connection.disconnect.hangup farend">
    <assign name="transduration" expr="my_transfer$.duration"/>
    <submit next="store_information.php" namelist="usernum transduration" method="post" enctype="multipart/form-data"/>
  </catch>
</form>
</vxml>
store_information.php:

Code: Select all

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

$File = "storeresults6.txt";
$Handle = fopen($File, 'a+');
$Date = date("r");
$UserNum = $_POST[usernum];
$Transduration = $_POST[transduration];
$Data = "$Date $UserNum $Transduration\n";
fwrite($Handle, $Data);
fclose($Handle);
?>

<vxml version="2.0">
  <form>
    <block>
      <exit/>
    </block>
  </form>
</vxml>
From this example, the user starts at main.php and if they enter 2, the <submit> tag does a transition to transferduration.php, sending a POST variable of "menuchoice". For transferduration.php, the user then hears that they entered 2 and to hold while they are transferred. From here, if the user is transferred successfully, the transfer duration will be stored in "transduration" and then passed to store_information.php as a POST variable through another <submit> tag.

For more information on how to do data exchange for your VXML pages or about the <submit> tag, please see our documentation here: http://www.plumvoice.com/docs/dev/devel ... taexchange
http://www.plumvoice.com/docs/dev/voicexml:tags:submit

Vandy1Fan
Posts: 5
Joined: Thu Aug 21, 2014 2:45 pm

Re: Submit to offsite url after transfer

Post by Vandy1Fan »

We figured out what happened.
The call to our site created a new script that contained the transfer.
We are changing it to handle the variable information.

Thanks for your help.

Post Reply