Esempio n. 1
0
def login_intent_handler(handler_input):
    """Handler for Login Intent."""
    # type: (HandlerInput) -> Response

    assistant = SafraAssistant()
    name = get_slot_value(handler_input=handler_input, slot_name="name")
    speech_text = assistant.login(name)
    handler_input.attributes_manager.session_attributes["assistant"] = assistant.serialize()

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).set_should_end_session(
        False).response
Esempio n. 2
0
def launch_request_handler(handler_input):
    """Handler for Skill Launch."""
    # type: (HandlerInput) -> Response

    assistant = SafraAssistant()
    handler_input.attributes_manager.session_attributes["assistant"] = assistant.serialize()

    speech_text = assistant.start_session()

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).set_should_end_session(
        False).response
Esempio n. 3
0
def get_balances_intent_handler(handler_input):
    """Handler for Get Balances Intent."""
    # type: (HandlerInput) -> Response

    assistant = SafraAssistant.deserialize(handler_input.attributes_manager.session_attributes.get("assistant"))
    speech_text = assistant.get_balances()

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).set_should_end_session(
        False).response
Esempio n. 4
0
def help_intent_handler(handler_input):
    """Handler for Help Intent."""
    # type: (HandlerInput) -> Response

    assistant = SafraAssistant.deserialize(handler_input.attributes_manager.session_attributes.get("assistant"))
    speech_text = assistant.get_help()

    return handler_input.response_builder.speak(speech_text).ask(
        speech_text).set_card(SimpleCard(
            "Easy Safra", speech_text)).response
Esempio n. 5
0
def find_received_transfer_from_name_intent_handler(handler_input):
    """Handler for Find Received Transfer From Name Intent."""
    # type: (HandlerInput) -> Response

    name = get_slot_value(handler_input=handler_input, slot_name="name")
    assistant = SafraAssistant.deserialize(handler_input.attributes_manager.session_attributes.get("assistant"))
    speech_text = assistant.find_received_transfer_from_name(name)

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).set_should_end_session(
        False).response
Esempio n. 6
0
def make_transfer_intent_handler(handler_input):
    """Handler for Make Transfer Intent."""
    # type: (HandlerInput) -> Response

    name = get_slot_value(handler_input=handler_input, slot_name="name")
    value = float(get_slot_value(handler_input=handler_input, slot_name="value"))
    description = get_slot_value(handler_input=handler_input, slot_name="description")
    assistant = SafraAssistant.deserialize(handler_input.attributes_manager.session_attributes.get("assistant"))
    speech_text = assistant.make_transfer(name, value, description)

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).set_should_end_session(
        False).response
Esempio n. 7
0
def play_morning_call_intent_handler(handler_input):
    """Handler for Play Morning Call Intent."""
    # type: (HandlerInput) -> Response

    assistant = SafraAssistant.deserialize(handler_input.attributes_manager.session_attributes.get("assistant"))
    (speech_text, url) = assistant.play_morning_call()

    return handler_input.response_builder.speak(speech_text).set_card(
        SimpleCard("Easy Safra", speech_text)).add_directive(
        PlayDirective(
            play_behavior=PlayBehavior.REPLACE_ALL,
            audio_item=AudioItem(
                stream=Stream(
                    token=url,
                    url=url,
                    offset_in_milliseconds=0,
                    expected_previous_token=None)
            )
        )
    ).set_should_end_session(True).response