def stop_and_cancel_intent_handler(handler_input):
    logger.info("== Received a Stop or a Cancel Intent.. ==")
    session_attr = handler_input.attributes_manager.session_attributes
    response_builder = handler_input.response_builder
    endpoint_id = session_attr['endpointId']

    ##
    ## When the user stops the skill, stop the EventHandler,
    ##
    if 'token' in session_attr.keys():
        try:
            logger.debug(
                "== Active session detected, sending stop EventHandlerDirective. =="
            )
            response_builder.add_directive(
                StopEventHandlerDirective(session_attr['token']))
        except Exception as e:
            logger.error('== EXCEPTION: %s ==', e)

    payload = {'intent': 'stop_cancel'}

    affirmation = random.choice(data.AFFIRMATIONS)
    message = data.CANCEL_STOP_MESSAGE

    msg = ' '.join([affirmation, message])

    return (response_builder.speak(msg).add_directive(
        build_ev3_directive(endpoint_id,
                            payload)).set_should_end_session(True).response)
Beispiel #2
0
def stop_and_cancel_intent_handler(handler_input):
    logger.info("Received a Stop or a Cancel Intent..")
    session_attr = handler_input.attributes_manager.session_attributes
    response_builder = handler_input.response_builder
    endpoint_id = session_attr['endpointId']

    # When the user stops the skill, stop the EventHandler,
    if 'token' in session_attr.keys():
        logger.debug("Active session detected, sending stop EventHandlerDirective.")
        response_builder.add_directive(StopEventHandlerDirective(session_attr['token']))

    return (response_builder
            .speak("Alright, see you later.")
            .set_should_end_session(True)
            .response)
Beispiel #3
0
def build_stop_event_handler_directive(token):
    return StopEventHandlerDirective(token=token)
def build_stop_event_handler_directive(token):
    logger.info("== build_stop_event_handler_directive ==")
    return StopEventHandlerDirective(token=token)