def test_get_intent_name_throws_exception_for_non_intent_request(self):
        test_input = self._create_handler_input(
            request=self.test_launch_request)

        with self.assertRaises(
                TypeError,
                msg="get_intent_name method didn't throw TypeError when an "
                    "invalid request type is passed"):
            get_intent_name(handler_input=test_input)
示例#2
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        response_hello = ["Hello!", "Booyah!", "What's kraken?!", "Hi!"]
        speak_output = random.choice(response_hello)

        return (handler_input.response_builder.speak(speak_output).response)
示例#3
0
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     intent_name = ask_utils.get_intent_name(handler_input)
     url = apiUrl + "?getline"
     response = requests.get(url).text
     return (handler_input.response_builder.speak(response).ask(
         response).response)
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     intent_name = ask_utils.get_intent_name(handler_input)
     speak_output = "You just triggered " + intent_name + "."
     # speak_output = "Sorry, I had trouble doing what you asked. Please try again."
     return (handler_input.response_builder.speak(speak_output).ask(
         speak_output).response)
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     intent_name = get_intent_name(handler_input)
     speech_text = ("You just triggered {}").format(intent_name)
     handler_input.response_builder.speak(
         speech_text).set_should_end_session(True)
     return handler_input.response_builder.response
示例#6
0
 def handle(self, handler_input):
     intent_name = ask_utils.get_intent_name(handler_input)
     speak_output = "You just triggered " + intent_name + "."
     return (
         handler_input.response_builder.speak(speak_output)
         # .ask("add a reprompt if you want to keep the session open for the user to respond")
         .response)
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "You just triggered " + intent_name + "."

        return (handler_input.response_builder.speak(speak_output).ask(
            "If you want to ask Einstein anything else, just say Hey Einstein and your question"
        ).response)
    def test_get_intent_name(self):
        test_input = self._create_handler_input(
            request=self.test_intent_request)

        self.assertEqual(
            get_intent_name(handler_input=test_input), self.test_intent_name,
            "get_intent_name method returned incorrect intent name for "
            "input request")
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "You just triggered " + intent_name + "."

        return (
            handler_input.response_builder.speak(speak_output).response
        )
示例#10
0
    def handle(self, handler_input: HandlerInput) -> Response:

        dialog = self.alexa_repository.get_dialog(
            ask_utils.get_intent_name(handler_input))

        return (handler_input.response_builder.speak(dialog.speak).ask(
            dialog.ask).response if dialog.ask else
                handler_input.response_builder.speak(dialog.speak).response)
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = 'You just triggered {}'.format(intent_name)

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "Sorry, I don't understand " + intent_name + "."

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
def intnt_name(handler_input):
    """
    Returns name of request or intent
    """
    req_type = get_request_type(handler_input)
    if req_type == "IntentRequest":
        return get_intent_name(handler_input)
    else:
        return req_type
示例#14
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = intent_name + "というインテントが呼ばれました。"

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#15
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        data = handler_input.attributes_manager.request_attributes["_"]
        speak_output = data[prompts.YOU_TRIGGERED].format(intent_name)

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#16
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        #speak_output = "You just triggered " + intent_name + "."
        speak_output = "Desculpe. Tive um problema. Por favor, recomece."

        return (
            handler_input.response_builder.speak(speak_output)
            # ".ask("add a reprompt if you want to keep the session open for the user to respond")"
            .response)
示例#17
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        _ = handler_input.attributes_manager.request_attributes["_"]
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = _(data.REFLECTOR_MSG).format(intent_name)

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#18
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "Intent: {0}".format(intent_name)

        return (
            handler_input.response_builder
            .speak(speak_output)
            .response
        )
示例#19
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "Sorry I am unable to help you at this time."
        logger.error("In Fallback Alexa Request: {}\n".format(
            handler_input.request_envelope.request))

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#20
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)

        _ = handler_input.attributes_manager.request_attributes["_"]
        speak_output = _(f"You just triggered {intent_name}")

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#21
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = i18n.t("strings.REFLECTOR_MSG", intent=intent_name)

        return (
            handler_input.response_builder
            .speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response
        )
示例#22
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "You just triggered " + intent_name + "."
        if intent_name == "deliver":
            speak_output = "sure, Will do."

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#23
0
    def handle(self, handler_input):
        # type: (handler_input) -> Response

        logger.info(">>>>> In IntentReflectorHandler")
        intent_name = ask_utils.get_intent_name(handler_input)
        logger.info("Triggered intent: %s", intent_name)
        speak_output = "You just triggered " + intent_name + "."

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#24
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "I do not understand what you asked, please try again. Say <b>Help</b> for to find the ways to ask equations."

        return (
            handler_input.response_builder
                .speak(speak_output)
                .set_should_end_session(False)
                # .ask("Do you want to me to figure another equation for you?")
                .response
        )
示例#25
0
    def handle(self, handler_input: HandlerInput) -> Response:

        locale = get_locale(handler_input)
        device_id = self.alexa_repository.get_device_id(
            "EnciendePiscinaIntent")
        iot_err = self.alexa_repository.send_order(device_id, True, 25)
        dialog = self.alexa_repository.get_dialog(
            ask_utils.get_intent_name(handler_input), iot_err, locale)

        return (handler_input.response_builder.speak(dialog.speak).ask(
            dialog.ask).response if dialog.ask else
                handler_input.response_builder.speak(dialog.speak).response)
示例#26
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        slots = handler_input.request_envelope.request.intent.slots
        i = slots['raw_input']
        intent_name = ask_utils.get_intent_name(handler_input)
        speak_output = "You said, '" + i.value + "'"

        return (
            handler_input.response_builder
                .speak(speak_output)
                .ask("")
                .response
        )
示例#27
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        logger.error("In Reflector Alexa Request: {}\n".format(
            handler_input.request_envelope.request))
        speak_output = "I do not understand what you asked, please try again. Say <b>Help</b> to find the ways to ask questions."
        logger.info(handler_input)
        print(handler_input)

        return (
            handler_input.response_builder.speak(speak_output)
            # .ask("add a reprompt if you want to keep the session open for the user to respond")
            .response)
示例#28
0
    def handle(self, handler_input):
        #What hall?
        hallSlot = ask_utils.get_slot(handler_input=handler_input,
                                      slot_name="hall")
        try:
            hallID = hallSlot.resolutions.resolutions_per_authority[0].values[
                0].value.id
        except:
            hallID = "ALL"

        #What day?
        dateValue = ask_utils.get_slot_value(handler_input=handler_input,
                                             slot_name="menuDate")
        if not dateValue:
            dateValue = ""

        #What meal?
        menuName = ask_utils.get_intent_name(handler_input)
        if menuName == "BreakfastMenu":
            meal = 0
        elif menuName == "LunchMenu":
            meal = 1
        elif menuName == "DinnerMenu":
            meal = 2

        if hallID == "ALL":
            page = self.pullA(dateValue, meal)
            output = [
                self.scrape(hall) for hall in page.findAll(class_="meal row")
            ]
            print("initial output complete")
            output = [
                "In Taylor Dining:", output[2], "In Thomas Dining:", output[3],
                "At Stevenson Deli: ", output[1], "At Stevenson Grill: ",
                output[0], "At the Union: ", output[4]
            ]
            print("output sorting complete")
            output = ";".join(output)
            print("output complete")
        else:
            page = self.pullH(hallID, dateValue, meal)
            output = self.scrape(page)

        return (handler_input.response_builder.speak(output).response)
示例#29
0
def unhandled_intent_handler(handler_input):
    # type: (HandlerInput) -> Response
    """Handler for all other unhandled requests."""
    intent_name = get_intent_name(handler_input)
    if intent_name == 'ChallengeBossIntent':
        speech_text = 'You need to be in the boss room to challenge the boss. '
    elif intent_name == 'EnterMazeIntent':
        speech_text = 'You already have a maze in progress. Would you like to resume the maze or discard the maze? '
    elif intent_name == 'ResumeMazeIntent' or intent_name == 'DiscardMazeIntent':
        speech_text = 'You are already in a maze or you don\'t have a maze in progress. Say enter the maze or discard the maze. '
    elif intent_name == 'LocationIntent':
        speech_text = 'You need to be in a maze to locate yourself. Say enter the maze or resume the maze. '
    elif intent_name == 'MoveIntent':
        speech_text = 'You need to be in a maze to take a move. Say enter the maze or resume the maze. '
    else:
        speech_text = 'I am not sure what you are saying. '

    handler_input.response_builder.speak(speech_text).set_should_end_session(
        False)
    return handler_input.response_builder.response
示例#30
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        intent_name = ask_utils.get_intent_name(handler_input)
        slots = handler_input.request_envelope.request.intent.slots

        if checklist_slot not in slots:
            speech = "I am not sure to understand. Please tell me which checklist you want"
            return handler_input.response_builder.speak(speech).ask(
                speech).response

        checklistName = slots[checklist_slot].value
        url = apiUrl + "?list=" + checklistName
        response = requests.get(url)
        logger.info("Response get checkist " + response.text)
        if response.status_code == 200 and not response.text == "FAIL":
            speech = response.text
        else:
            instructions = "I am so sorry. I am not able to get the checklist " + checklistName + ".\n"
            askQuestion = "Do you have another checklist?"
            instructions += askQuestion
            speech = instructions
        return handler_input.response_builder.speak(speech).ask(
            speech).response