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.