如何进入 Alexa Skills 中的下一个功能

How to get to next function in Alexa Skills

我是建立 alexa 技能的新手,我正在尝试建立一种读取您的 wifi 密码的技能。将来我想使它动态化,以便有人可以添加自己的 wifi 密码并将其读回给他们。现在我的密码是硬编码的。我想提示 alexa 向用户询问特定的密码(现在我也有这个硬编码)。如果密码正确,读出存储的wifi密码。问题是我不确定如何获得第二个功能。这是用户和 Alexa 之间的对话流程。

用户:"Alexa, what is my wifi password?"

Alexa:"What is your passphrase?"

用户:"bravo."

如果密码正确 亚历克莎:"Thanks. Your wifi password is P A S S W O R D."

如果密码不正确 亚历克莎:"Passphrase incorrect. What is your passphrase?"

这是我的 GetPassword 函数。

const GetPassword = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
    },
    handle(handlerInput) {
        const speakOutput = "What is the passphrase?"
        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};

这是我的 CheckPhrase 函数。

const CheckPhrase = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest';
    },
    handle(handlerInput) {
        const speakOutput = "Your password is, YOUR_WIFI_PASSWORD"
        return handlerInput.responseBuilder
            .speak(speakOutput)
            .reprompt(speakOutput)
            .getResponse();
    }
};

我的意图是当用户 says/types 在第一个函数 运行 之后的短语中执行 CheckPhrase。我可以很好地访问第一个函数,系统会提示我输入密码。但是当我输入密码时,它只是重复之前的提示。我曾尝试使用 if/else 语句来验证用户的输入,但我不确定如何访问正确的值。我还尝试在 GetPasswordresponseBuilder 中调用 CheckPhrase 来执行密码回读。我也尝试过使用 reprompt 但我相信如果该技能在一定时间后未收到用户输入,则更多。

如果这些是亚马逊技能开发的基本方面,我深表歉意,但我已经阅读了文档,也许我没有使用正确的措辞来搜索我正在寻找的内容,但它无济于事。我看过一些关于 SO 的帖子,但我没能找到任何与输入验证或使用辅助功能相关的问题。

我的代码目前托管在 Alexa 控制台中,而不是 Lambda(我不确定这是否相关)。我目前没有使用任何插槽。

听起来您需要确认插槽。从官方文档中查看此页面:https://developer.amazon.com/en-US/docs/alexa/custom-skills/define-the-dialog-to-collect-and-confirm-required-information.html

旁注:一旦代码按预期工作,您可能需要使用一些 SSML 来拼写密码:https://forums.developer.amazon.com/questions/190384/how-configure-alexa-to-confirm-numeric-slots-input.html