【发布时间】:2021-02-14 22:25:56
【问题描述】:
我有一个自定义意图,即从 Google 助理接收 2 个文本参数。但助手不会启动我的应用程序。我只试过一个,它工作正常。问题是当我添加第二个文本参数时。我尝试过使用另一种数据类型并且它有效。例如,如果我要求一个文本和一个数字,效果很好。如果我要求文本和时间,它也有效。但是,如果我要求一个文本和一个文本,那么它不会。请问这里有什么帮助吗? 这是我在 actions.xml 文件中的意图:
<action intentName="custom.actions.intent.MyName" queryPatterns="@array/MyExampleStrings">
<!-- Define parameters -->
<parameter name="textA" type="https://schema.org/Text" />
<parameter name="textB" type="https://schema.org/Text" />
<!-- Define fulfillment -->
<fulfillment urlTemplate="https://my.site.com/{?FirstText,SecondText}">
<parameter-mapping intentParameter="textA" urlParameter="FirstText" />
<parameter-mapping intentParameter="textB" urlParameter="SecondText" />
</fulfillment>
</action>
MyExampleStrings 类似于“使用 $textB 烘焙 $textA”,例如“用番茄烘焙意大利面”。
正如我之前所说,它适用于不同的数据类型。在下一个示例中,我更改了数字的第二个文本,它可以工作:
<action intentName="custom.actions.intent.MyName" queryPatterns="@array/MyExampleStrings">
<!-- Define parameters -->
<parameter name="textA" type="https://schema.org/Text" />
<parameter name="textB" type="https://schema.org/Number" /> <--NUMBER!
<!-- Define fulfillment -->
<fulfillment urlTemplate="https://my.site.com/{?FirstText,SecondText}">
<parameter-mapping intentParameter="textA" urlParameter="FirstText" />
<parameter-mapping intentParameter="textB" urlParameter="SecondText" />
</fulfillment>
</action>
在这种情况下,如果我说“用 4 烤意大利面”之类的话,它会起作用。 为什么我不能有两个字符串??? 感谢您的帮助
【问题讨论】:
-
我不熟悉 Google 的帮助,这不是一种解决方案,而是一种可能对您有用的解决方法,直到您找到更好的解决方法。为什么不发送一个文本并在里面添加一个特殊的分隔符?比如,spaghetti@Tomatoes 或类似的东西,一旦你在你的活动中得到文本,只需用这个字符分割并使用这些值。
标签: android actions-on-google app-actions