在Action.xml App Action URL模板中,{@url}的用途是什么?



在我的Action.xml文件中,我可以使用<entity-set>标签为我的意图参数提供清单。对于每个<entity>,文档表示我可以指定identifierurl的值。identifierurl有什么区别?如果使用identifier,为什么我需要<parameter-mapping>标签,但如果我使用url

关键区别在于 identifier值是URL排出的。例如:

<intent name="actions.intent.SOME_INTENT">
  <parameter name="param.name">
    <entity-set-reference entitySetId="identifier_entity_set">
  </parameter>
  <fulfillment urlTemplate="https://app.com/{param_value}">
    <parameter-mapping intentParameter="param.name" urlParameter="param_value" />
  </fulfillment>
</intent>
<entity-set entitySetId="identifier_entity_set">
  <entity identifier="escaped/url/path" name="hi">
</entity-set>

如果用户说"嗨"对于param.name,已解决的urltemplate将为:https://app.com/escaped/url/path。

<intent name="actions.intent.SOME_INTENT">
  <parameter name="param.name">
    <entity-set-reference entitySetId="url_entity_set">
  </parameter>
</intent>
  <fulfillment urlTemplate="{@url}" />
<entity-set entitySetId="url_entity_set">
  <entity url="https://app.com/not/esacaped/url/path" name="bye">
</entity-set>

如果用户说"再见"对于param.name,已解决的urltemplate将为:https://app.com/not/esacaped/url/path。

另外,请注意,如果您在urltemplate中具有{@url},则不应为其包含<parameter-mapping>;假定您完全有一个<entity-set>具有url值。

最新更新