1

I have an interesting task that I am trying to accomplish. While using VoiceXML, I'd like to have a caller call into a number, and then be transferred to number #1. If the caller is not connected (no answer) then the destination number is changed and the caller is then attempted to be connected to the second number.

I was given a little information by the support tech that stated:

The best option would be define a list of numbers in JavaScript, if the transfer is unsuccessful, pop the next of the list, and repeat the transfer (which means the 'dest' for the transfer would be a variable).

But I am not sure how to go about this, and so far, I'm unable to find any reference points to use for this. Could this be achieved by using PHP, maybe?

How can I add JavaScript to VoiceXML that would allow me to set a timeout variable on the transfer tag, and then cycle through the numbers if the caller isn't connected?

halfer
  • 19,824
  • 17
  • 99
  • 186
MrTechie
  • 1,797
  • 4
  • 20
  • 36

1 Answers1

1

Assuming that you use a VoiceXML 2.1 compliant platform, you must use something like <transfer type="consultation" destexpr="myDestinationVariable" connecttimeout="20s" />.

However, the connecttimeout attribute cannot be a JavaScript expression, it must be a time literal. So you need to generate VoiceXML on the fly (with PHP or something else) if the time-out is not a constant.

If you can have a constant timeout, you could do something like (not tested):

<?xml version="1.0" encoding="utf-8"?>
<vxml version="2.1" xml:lang="en-US" xmlns="http://www.w3.org/2001/vxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <var name="destinations" expr="['5555551111', '5555551112', '5555551113']" />
  <var name="currentDestination" expr="destinations.shift()" />

  <form id="myForm">

    <transfer name="transferResult" type="consultation" cond="currentDestination!=undefined" destexpr="currentDestination"
  connecttimeout="20s">
      <filled>
        <if cond="transferResult=='noanswer'">
          <assign name="currentDestination" expr="destinations.shift()" />
          <clear />
        </if>
      </filled>

      <catch event="connection.disconnect.transfer">
        <!-- transfer OK -->
      </catch>
    </transfer>

    <block>
      <!-- No more numbers to try -->
    </block>

  </form>
</vxml>
gawi
  • 13,940
  • 7
  • 42
  • 78
  • that doesn't answer the question about using javascript to cycle through numbers. I already know about the timeout feature – MrTechie Mar 04 '15 at 14:47
  • Does your "connect timeout" really need to be a variable, i.e. does it change from one destination to another or you can hard-code a constant like 20s? – gawi Mar 04 '15 at 18:09
  • the timeout variable isn't really what's in question here. What is more important is the cycling of numbers. But I did figure out a way to accomplish this without using javascript. Basically created a few form blocks and then bounce things around using the – MrTechie Mar 04 '15 at 23:21