Created
August 24, 2016 19:27
-
-
Save BadBinary/58a869f38a91279030b81b818cac6e76 to your computer and use it in GitHub Desktop.
Alexa Skills Kit Help Intent Fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Below is the new corrected handleGetHelpRequest function for the FlashCard template and ReindeerGames Template | |
function handleGetHelpRequest(intent, session, callback) { | |
// Provide a help prompt for the user, explaining how the game is played. Then, continue the game | |
// if there is one in progress, or provide the option to start another one. | |
// Set a flag to track that we're in the Help state. | |
// Changes to logic to resolve new certification test cases | |
// Help intent now checks to see if a game is in progress before providing help, else it will prompt to start new game | |
var gameInProgress = session.attributes; | |
var sessionAttributes = {}; | |
if (!gameInProgress) { | |
// If the user asked for help but there is no game in progress, ask the user | |
// if they want to start a new game. Set a flag to track that we've prompted the user. | |
sessionAttributes.userPromptedToContinue = true; | |
speechOutput = "I will ask you to provide the name of an element in the periodic table. I will provide the abbreviation, you will need to provide the name. " | |
+ "For example, If the element is A R, you would say Argon. To start a new game at any time, say, start new game. " | |
+ "To repeat the last element, say, repeat. " | |
+ "Would you like to start playing?", | |
repromptText = "To give an answer, respond with the correct element. " | |
+ "Would you like to start playing?"; | |
callback(sessionAttributes, | |
buildSpeechletResponse(CARD_TITLE, speechOutput, speechOutput, false)); | |
} else if (gameInProgress) { | |
session.attributes.userPromptedToContinue = true | |
// Do not edit the help dialogue. This has been created by the Alexa team to demonstrate best practices. | |
var speechOutput = "I will ask you to provide the name of an element in the periodic table. I will provide the abbreviation, you will need to provide the name. " | |
+ "For example, If the element is A R, you would say Argon. To start a new game at any time, say, start new game. " | |
+ "To repeat the last element, say, repeat. " | |
+ "Would you like to keep playing?", | |
repromptText = "To give an answer, respond with the correct element. " | |
+ "Would you like to keep playing?"; | |
var shouldEndSession = false; | |
callback(session.attributes, | |
buildSpeechletResponseWithoutCard(speechOutput, repromptText, shouldEndSession)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm lost.