假设您使用符合 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>