Created
February 22, 2020 11:33
-
-
Save kinisoftware/741ee22ece7c35c05900a2f2a4141049 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class EscogerComidaIntent : RequestHandler { | |
| override fun canHandle(input: HandlerInput): Boolean { | |
| return input.matches(Predicates.intentName("escoger_comida")) | |
| } | |
| override fun handle(input: HandlerInput): Optional<Response> { | |
| if (!input.attributesManager.sessionAttributes.containsKey(AttributeConstants.FOOD) | |
| || !input.attributesManager.sessionAttributes.containsKey(AttributeConstants.RESTAURANT) | |
| ) { | |
| return input.responseBuilder | |
| .withSpeech("Comienza seleccionando el tipo de comida como pizza o hamburguesa") | |
| .withShouldEndSession(false) | |
| .build() | |
| } | |
| val request = input.requestEnvelope.request | |
| val intentRequest = request as IntentRequest | |
| val intent = intentRequest.intent | |
| val slots = intent.slots | |
| val order = slots["comprar"]!!.value | |
| val restaurant = input.attributesManager.sessionAttributes[AttributeConstants.RESTAURANT] | |
| val text = "Okay, ¡gran elección! Vamos a comprar $order en $restaurant." | |
| return input.responseBuilder | |
| .withSpeech(text) | |
| .withShouldEndSession(true) | |
| .build() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment