Created
August 26, 2018 18:42
-
-
Save reaganmcf/c0d9814435688ffca46a81a83b05b14e to your computer and use it in GitHub Desktop.
RemoveChoreIntentHandler updated
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
/** | |
* Handler for the RemoveChoreIntent | |
*/ | |
const RemoveChoreIntentHandler = { | |
canHandle(handlerInput) { | |
const { request } = handlerInput.requestEnvelope; | |
return ( | |
request.type === Requests.INTENT_REQUEST && | |
request.intent.name === Intents.REMOVE_CHORE_INTENT | |
); | |
}, | |
async handle(handlerInput) { | |
const { request } = handlerInput.requestEnvelope; | |
const choreSlot = request.intent.slots.choreName; | |
let choreName; | |
if (choreSlot && choreSlot.value) { | |
choreName = choreSlot.value.toLowerCase(); | |
} | |
let speakOutput = Messages.ERROR_NO_CHORE_SLOT; | |
if (choreName) { | |
const success = await API.removeChore(choreName); | |
speakOutput = Messages.ERROR_REMOVING_CHORE; | |
if (success) { | |
speakOutput = `Successfully removed ${choreName}`; | |
} | |
} | |
return handlerInput.responseBuilder.speak(speakOutput).getResponse(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment