如何在VXML中连接varible。考虑下面的示例VXML,
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/vxml" version="2.0" xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd">
<form>
<block>
<audio src="{url1}"/>
<audio src="{url2}"/>
</block>
<field name="dtmf">
<option dtmf="1" value="1"/>
<option dtmf="2" value="2"/>
<option dtmf="2" value="3"/>
<filled>
<submit next="{url3}" namelist="action toneId dtmf" method="get"/>
</filled>
</field>
<noinput>
<reprompt/>
</noinput>
<nomatch>
<reprompt/>
</nomatch>
</form>
</vxml>{ url3 } ={一些字符串}+{一些variable=value},我想这样做,有两个值url3连接。
发布于 2015-09-02 19:07:32
更改:
<submit next="{url3}" namelist="action toneId dtmf" method="get"/>至
<submit expr="{some string} + {some variable=value}" namelist="action toneId dtmf" method="get"/>或者更具体的例子:
<submit expr="'http://yourserver.com/api/' + servletName" namelist="action toneId dtmf" method="get"/>发布于 2015-09-03 02:21:08
前面的答案是正确的,但让我再添加一两行,说明如何使用namelist和field。
<field name="dtmf">您正在定义变量名,在文档的其他地方使用"dtmf“;让我们将其称为”响应“,以避免出现问题。
<field name="response">您可以考虑选项,这是很好的:
<option dtmf="1" value="1"/>
<option dtmf="2" value="2"/>
<option dtmf="2" value="3"/>当然,这些值可以是任何东西,例如
<option dtmf="1" value="meat"/>
<option dtmf="2" value="fish"/>
<option dtmf="2" value="dairy"/>我想在这里指出,上面的value不接受而不是接受ECMAScript值;它只是纯文本,VoiceXML的一个奇怪之处。
设置要发送的其他变量的值:
<var name="toneId" expr="12"/>
<var name="action" expr="'scream'"/>expr 确实需要ECMAScript表达式。"toneID“设置为数字,"action”设置为字符串。如果您需要这样做,也可以这样做:
<var name="foo" expr="'scream'"/>
<var name="action" expr="foo"/> 字段"response“将自动填写用户选择的值。如果您愿意,也可以使用所谓的“影子变量”,并将它们发送;请参阅VoiceXML规范 http://www.w3.org/TR/2004/REC-voicexml20-20040316/#dml2.3.1。
最后,正如吉姆所说,
<submit expr="'http://example.com/api/' + servletName" namelist="action toneId response" method="get"/>希望这能有所帮助。
https://stackoverflow.com/questions/32351207
复制相似问题