0
votes

I am new to building alexa skills, and I am trying to build a skill that reads your your wifi password. In the future I want to make this dynamic so that someone can add their own wifi passwords and have it read back to them. For now my password is hardcoded. I want to prompt alexa to ask the user for a specific passphrase (for now I also have this hardcoded). If the passphrase is correct, read out the stored wifi password. The problem is I am not sure how to get to the second function. Here is the flow of conversation between the user and Alexa.

User: "Alexa, what is my wifi password?"

Alexa: "What is your passphrase?"

User: "bravo."

If correct passphrase Alexa: "Thanks. Your wifi password is P A S S W O R D."

If incorrect passphrase Alexa: "Passphrase incorrect. What is your passphrase?"

Here is my GetPassword function.

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();
    }
};

And here is my CheckPhrase function.

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();
    }
};

My intention was to execute CheckPhrase when the user says/types in a phrase after the first function is run. I can reach the first function just fine, and I am prompted to to enter a passphrase. But when I enter the passphrase it just repeats the previous prompt. I have tried using an if/else statement to validate the user's input but I'm not really sure how to access the correct value. I also tried calling CheckPhrase within the responseBuilder of GetPassword that just executed the password read back. I've also tried using reprompt but I believe that is more for if the skill has not received user input after a certain amount of time.

I apologize if these are rudimentary aspects of amazon skill development but I've read the docs and maybe I am not using the right phrasing to search for what I am looking for but it has been to no avail. I have seen a few posts on SO but I haven't been able to find any questions that relate to input validation or using secondary functions.

My code is currently hosted in the Alexa console and not Lambda (I'm not sure if that is relevant). And I am currently not using any slots.

1
Can you update the flow conversation between Alexa and the user so that we can understand your problem clearly?sharan kenam
@sharankenam Updated the flow. The part I'm stuck at is having Alexa check the passphrase and if it's correct, read password, otherwise repeat question.Matt Croak

1 Answers

2
votes

It sounds like you need slot confirmation. Check out this page from the official docs: https://developer.amazon.com/en-US/docs/alexa/custom-skills/define-the-dialog-to-collect-and-confirm-required-information.html

Sidenote: you will probably need to use some SSML to spell out your password once the code is working as expected: https://forums.developer.amazon.com/questions/190384/how-configure-alexa-to-confirm-numeric-slots-input.html