如何在用户打开技能时验证用户的 PIN (LaunchRequest)

How to verify a user's pin when they open the skill (LaunchRequest)

我的 Alexa 技能有一些问题。我希望对话是这样进行的:

User: 'Alexa, open party'

Alexa: 'Hello, what is your four digit secret pin?'

User: '1234'

Alexa: 'Confirmed, what can I help you with?'

但我对如何构建它感到困惑。我需要获取用户的密码并在我的代码库中对其进行验证。我知道您无法让对话委托在 LaunchRequest 内部工作。 LaunchRequest 无法自定义,因此我无法为其添加插槽。我在互联网上找不到任何其他 suggestions/examples。有没有人以前做过这个或者有什么建议吗?

亚马逊支持account linking as the method to connect users with their other accounts. This allows users to log into their other account using OAuth at the time the skill is installed. While it may be possible to determine a user based on the session object userid,这样的技巧可能很难发表

事实证明,您无法在 LaunchRequest 内将插槽收集委托给 Alexa,因为它不是 LaunchRequest 的有效 response type 的一部分。

我最初的逻辑是:

  1. 用户说'Alexa, open party'
  2. Alexa 技能调用 LaunchRequest。 (此时我需要通过委托 Alexa 进行插槽收集来向用户询问他们的密码)
  3. LaunchRequest 中,立即用 this.emit(':getPinIntent'); 响应,其中 getPinIntent 是我的 Alexa Skill 中存在的另一个意图。上面的代码是我在网上看到的如何调用另一个intent而无需用户使用语音来调用的代码。
  4. getPinIntent 被调用并立即检查是否所有必需的槽都已填充(即槽 PIN 是否有值)。如果他们不是并且 dialogState !== 'COMPLETED' 那么我将插槽集合委托给 Alexa。
  5. 上面的步骤 (#4) 是出了问题的地方。因为委托不是 LaunchRequest 的有效响应类型,所以没有字段 dialogueState 是委托给 Alexa 所必需的。 Alexa 请求仍然是 LaunchRequest 而不是 Intent 请求,因为用户没有通过对 Alexa 说话来调用 Intent。
  6. 总而言之,这不是完成对话的有效方式,在这种对话中,启动时要求用户输入 PIN,然后只需说出 PIN 即可回复,如下图所示:

User: "Alexa, open party"

Alexa: "What is your pin" (alexa never gets here, because of #4 and #5 above)

User: "one two three four"

Alexa: "Confirmed, what can I help you with?"

如果我有任何错误或错误的假设,请告诉我。

我现在的逻辑已经改变了。如果您不使用 Skill Builder Beta,您可以有一个插槽作为您的一个意图的话语存在。所以我现在有 getPinIntent 和一个名为 {PIN} 的槽和 {PIN} 形式的话语。这让上述类型的对话发生了,因为当用户说出他或她的 pin back(“一二三四”)时,它会启动 getPinIntent 然后我可以继续或将对话委托给 Alexa 因为对于 IntentRequest 对话框是有效的 response type.

我现在遇到的唯一问题是,因为我没有使用 Skill Builder Beta,所以我无法(或没有找到方法)添加我的 Intent Schema 的对话模型 to/inside。在添加正确的对话模型后,我尝试将 JSON 文本从 Skill Builder Beta 复制到我的 Intent Schema 中,但这总是会导致构建错误。

所以现在我可以完成用户的 pin 身份验证并以“我能提供什么帮助”作为响应,但是之后出现的 IntentRequest 可能需要委托给 Alexa 进行插槽,这会导致崩溃,因为没有 Skill Builder Beta 我无法为 Alexa 添加适当的对话模型以在委托插槽收集期间使用。