1

我有一个有趣的任务,我正在努力完成。在使用 VoiceXML 时,我想让来电者呼叫一个号码,然后转接到号码 #1。如果呼叫者未连接(无应答),则更改目标号码,然后尝试将呼叫者连接到第二个号码。

支持技术人员向我提供了一些信息,内容如下:

最好的选择是在 JavaScript 中定义一个数字列表,如果传输不成功,弹出列表的下一个,然后重复传输(这意味着传输的“目标”将是一个变量)。

但我不知道该怎么做,到目前为止,我找不到任何参考点可以用来做这件事。这可以通过使用 PHP 来实现吗?

如何将 JavaScript 添加到 VoiceXML 以允许我在传输标签上设置超时变量,然后在呼叫者未连接时循环显示号码?

4

1 回答 1

1

假设您使用符合 VoiceXML 2.1 的平台,您必须使用类似<transfer type="consultation" destexpr="myDestinationVariable" connecttimeout="20s" />.

但是,connecttimeout属性不能是 JavaScript 表达式,它必须是时间文字。因此,如果超时不是常数,您需要动态生成 VoiceXML(使用 PHP 或其他工具)。

如果你可以有一个恒定的超时,你可以做类似的事情(未经测试):

<?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>
于 2015-03-04T11:23:02.013 回答