即使用户的对话属于其他意图,如何触发 fallbackIntent

How to fire fallbackIntent even if user's dialogue fall into some other intent

我正在开发一个应用程序,一切正常。一种情况是我已经设置了话语,但如果用户说的是别的东西,我会将其扔给 fallbackIntent。我的话语之一是 {name} 所以用户可以说出任何名字。但是我也定义了名称范围,用户只能使用这些名称。所以我的问题是,如果用户选择定义的名称,一切都很好,如果用户说了别的东西,比如芝加哥的天气,它也会 fallbackIntent 但问题是如果用户说出某个名字是不在列表中,那么它也进入了明确的意图。我想要的是,如果用户说的是正确的但不是我定义的名称,那么也将其重定向到 fallbackIntent。有什么办法可以称为提供条件的意图吗?我正在使用 php.

当您定义自定义槽时,Alexa 会将其值作为样本。因此,不在 slot-value-list 中的值也将传递给您。考虑到您的意图,这些插槽值是有效的,因此会触发该意图。

解决方案是在后端验证插槽值并return适当的响应。

在您的情况下,如果您得到除您定义的名称之外的任何其他名称,请回复错误或给出 FallbackIntent 的回复。

When you create a custom slot type, a key concept to understand is that this is training data for Alexa’s NLP (natural language processing). The values you provide are NOT a strict enum or array that limit what the user can say. This has two implications

1) words and phrases not in your slot values will be passed to you,

2) your code needs to perform any validation you require if what’s said is unknown.