Skip to content

Instantly share code, notes, and snippets.

@frivas
Last active October 23, 2018 15:37
Show Gist options
  • Save frivas/b2e76fce2ab94a9c8ab86ad8e177c625 to your computer and use it in GitHub Desktop.
Save frivas/b2e76fce2ab94a9c8ab86ad8e177c625 to your computer and use it in GitHub Desktop.
ListItemsIntentHandler. Medium Article. Creating an Alexa Skill Using Python
class ListItemsIntent(AbstractRequestHandler):
def can_handle(self, handler_input):
return is_intent_name("ListItemsIntent")(handler_input)
def handle(self, handler_input):
slots = handler_input.request_envelope.request.intent.slots
defaultObjsToSearch = 3
for slotName, currentSlot in six.iteritems(slots):
if slotName == 'numObj':
if currentSlot.value:
objsToSearch = sample(searchObjects, int(currentSlot.value))
else:
objsToSearch = sample(searchObjects, defaultObjsToSearch)
speechText = "<say-as interpret-as=\"interjection\">Magnífico!</say-as>. Aquí van, prestad atención: {0}. A divertirse!. <say-as interpret-as=\"interjection\">Suerte!</say-as>.".format(", ".join(objsToSearch))
logger.info(objsToSearch)
logger.info(speechText)
return handler_input.response_builder.speak(speechText).response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment