使用 Alexa 询问丢失的数据库数据

Ask for missing DB data with Alexa

我正在尝试使用 Alexa 执行以下操作:

我确实尝试过使用

this.emit(":delegate", "name_add");

从你说 "open APP_NAME" 时触发的 Intent,这意味着在 Hello Intent 中我进行查询,检查我是否有名称,如果没有我想触发另一个 Intent获取丢失的数据。

但是当我使用 Delegate 时,"name_add" 意图没有被触发。

我的问题

当我的意图依赖于数据库中的数据时,我发现缺少数据,我应该如何收集这些丢失的数据?请注意,一旦这些数据在数据库中,我就不会向用户询问。所以这是一次性的事情。

意思是我知道如何利用插槽,例如当你问你从哪里飞到哪里时。因为这是 Alexa 每次都会问的问题。但是,当您需要执行一次时怎么办?

问题是,您不能委托给新的意图。 Read about Dialog Directives here.

Note that you cannot change intents when returning a Dialog directive, so the intent name and set of slots must match the intent sent to your skill.

所以你将不得不重组你的意图。

建议结构:
通常情况下,你的helloIntent(当用户打开你的技能时'naked':"Alexa, open mySkill."而不是'with clothing':"Alexa, open mySkill and do something"),这个时候你要引导用户说出要做什么会触发你的主要意图。

因此 helloIntent 将简单地响应:"Hello, welcome to mySkill, you can say things like, do something, or, do something else"

然后用户说了其中一个,这是你其他意图的表达,因此触发了其中一个意图,让我们调用一个:"checkDatabase".

现在您已进入 "checkDatabase" 意图,您可以拥有一个名为 name 的必需插槽。此时您可以检查数据库中的用户名并自己填写插槽,或者委托回 Alexa 以引出 name.

要知道的事情:
1) Delegate 仅适用于意图所需的插槽。您正在委托 Alexa 来确定需要填充哪些插槽以及首先引出哪些插槽。她根据您在控制台中为意图设置的所需槽的顺序来计算这一点。

2) this.emit(':delegate', updatedIntent);(使用 Alexa SDK)需要第二个参数 updatedIntent 作为包含名称、插槽和确认状态的完整意图信息的对象(see Intent Object here ).如果您自己填充插槽,这就是您 return 'updated' 意图信息的方式。

3) 要更好地控制在哪些插槽中引出特定消息,请使用 ElicitSlot Directive。 在 Alexa SDK 中是:this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech, updatedIntent) Read about that here.
(必须使用 ElicitSlot 来引出不需要的插槽)