在JavaScript和vxml中使用多个传输号码

问题描述 投票:1回答:1

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

支持技术人员向我提供了一些信息:

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

但我不知道如何解决这个问题,到目前为止,我无法找到任何可用于此的参考点。这可以通过使用PHP来实现吗?

如何在VoiceXML中添加JavaScript,允许我在传输标签上设置超时变量,然后在未连接调用者的情况下循环显示数字?

javascript php vxml voicexml
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>
© www.soinside.com 2019 - 2024. All rights reserved.