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

name$.duration available on hangup?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
pinkatron
Posts: 6
Joined: Wed Sep 28, 2005 11:55 am

name$.duration available on hangup?

Post by pinkatron »

related to my previous message re: recording duration, i've noticed that the variable name$.duration is only available on dtmf-terminated recordings.

I am currently using a catch block to submit any recording that is terminated by a hangup. However, in this case the duration variable is not available.

The docs say as much; my question is, can this be made available? How might I escalate such a request?

thank you,

-Todd

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

IVR issue with variable scoping

Post by support »

Hello,

The IVR problem you are experiencing is variable scoping. The name$.duration you are referring to is only available at the form level it was captured. What this means is that in order to use the name$.duration variable you will have to have your <catch> block inside of the same form as the <record> tag:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
<form id="form1">
  <record name="test">
    <prompt>Please record something</prompt>
    <filled>
      <value expr="test$.duration"/>
    </filled>
    <catch event="connection.disconnect.hangup">
      <log><value expr="test$.duration"/></log>
    </catch>
  </record>
</form>
</vxml>
The following IVR code fails because the test variable is no longer in the scope of the catch element and its contents are lost:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
<catch event="connection.disconnect.hangup">
  <log><value expr="test$.duration"/></log>
</catch>
<form id="form1">
  <record name="test">
    <prompt>Please record something</prompt>
    <filled>
      <value expr="test$.duration"/>
    </filled>
  </record>
</form>
</vxml>
Regards,
Plum Support
Last edited by support on Thu Feb 25, 2010 2:22 pm, edited 3 times in total.

pinkatron
Posts: 6
Joined: Wed Sep 28, 2005 11:55 am

record variables not in scope on hangup?

Post by pinkatron »

Hi support, I asked a related question long ago, but this issue is coming up again:

i have a <record> block like this :

Code: Select all

<record name="audiomsg"> 
	<catch event="connection.disconnect.hangup">
<var name="duration" expr="audiomsg$.duration"/>
<submit next="http://mydomain.com/" namelist="audiomsg duration" method="post" enctype="multipart/form-data"/>
</catch>

<filled>
<var name="duration" expr="audiomsg$.duration"/>
<submit next="http://mydomain.com" namelist="audiomsg duration" method="post" enctype="multipart/form-data"/>
</filled>
</record>
note that both the <filled> and <catch> blocks are inside the record message.


this works, for the cases when a user records a message and hangs up, but when a user calls, and hangs up *before* leaving a message, or leaving a very short (<1sec) message, then some of the record variables are missing; specifically, this line :

VXI::var_element(name="duration" expr = "audiomsg$.duration")

which appears in the log during a successful recording, throws an error on an unsuccessful one, saying that $audiomsg$.duration is not available.

It's odd, in that the hangup catch block is obviously catching the hangup event, but at that point the variable does not seem to be available.

Ideally, it would exist but contain a null or zero value. That way my application can look at the duration, regardless of the situation, and determine what to do with the message based upon that.

Can you explain what is happening here, or what I can do to obtain the $audiomsg.duration variable?

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

IVR workaround using <var> for bug in platform

Post by support »

This appears to be a bug in the IVR platform. It should be returning "NULL" as the value of audiomsg$ rather than leaving it undefined. We will attempt to get the IVR platform patched to resolve this permanently.

In the meantime use the IVR tag, <var>, for a workaround:

Code: Select all

<var name="duration" expr="typeof audiomsg$ == 'undefined' ? 0 : audiomsg$.duration"/>
This will set duration to 0 if audiomsg$ is undefined.
Last edited by support on Thu Feb 25, 2010 2:23 pm, edited 2 times in total.

locamoda
Posts: 1
Joined: Tue Nov 01, 2005 1:31 pm

record variables not in scope on hangup?

Post by locamoda »

thanks -- that works like a charm.

I don't recall the 'typeof' syntax being discussed in the Plum online docs; is it in there? I'm wondering what other programatic controls I'm missing out on.

thanks again,

-Todd

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

IVR doc contains ECMAScript Language Specifications

Post by support »

Hello,

This is actually a ECMAScript capability. Plum uses a standards compliant ECMAScript interpreter where specified by the VoiceXML specification. The typeof syntax is a safe way to check to see if that variable has been initialized. This syntax can be found by going to Plum's IVR "Programmer's Reference Manual" and then viewing the "ECMAScript Language Specification" located at the top of the IVR document.

Regards,
Plum Support

Post Reply