def get_handler():
    sb = StandardSkillBuilder(table_name="GoogleClassroomStates",\
        auto_create_table=True)
    sb.add_request_handler(PermissionChangedEventHandler())
    sb.add_request_handler(ProactiveSubscriptionChanged())
    sb.add_request_handler(AccountLinkedEventHandler())
    return sb.lambda_handler()
Beispiel #2
0
    def handle(self, handler_input):
        speech = "Sorry , I didn't got you , I can help you detect depression ."
        reprompt = "You can say continue or start over"

        handler_input.response_builder.speak(speech).ask(reprompt)
        return handler_input.response_builder.response


class ResponseLogger(AbstractResponseInterceptor):
    """Log the alexa responses."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.debug("Alexa Response: {}".format(response))


skill_builder.add_request_handler(LaunchSkillHandler())
skill_builder.add_request_handler(CancelOrStopIntentHandler())
skill_builder.add_request_handler(StartOrContinueQuestionsHandler())
skill_builder.add_request_handler(QuestionResponseIntentHandler())
skill_builder.add_request_handler(SessionEndedRequestHandler())
skill_builder.add_request_handler(StartOverIntentHandler())
skill_builder.add_request_handler(HelpIntentHandler())
skill_builder.add_request_handler(FallbackIntentHandler())

# Utility functions


def get_depression_category_from_score(score):
    """

    :rtype: str
class SaveSessionAttributesResponseInterceptor(AbstractResponseInterceptor):
    """

    R E S P O N S E   I N T E R C E P T O R

    Response interceptors are invoked immediately after execution of the request handler for an incoming request.
    """
    def process(self, handler_input, response):
        print("Response generated: {}".format(response))
        print("Viewport detected: {}".format(device.apl_support))

        handler_input.attributes_manager.session_attributes = planet_story.get_session_variables(
        )


sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

# region Store handlers
sb.add_request_handler(UpsellResponseHandler())
sb.add_request_handler(RefundPurchaseHandler())
sb.add_request_handler(WhatCanIBuyHandler())
sb.add_request_handler(BuyHandler())
sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(ToggleVoiceHandler())

# endregion

# region Custom handlers
Beispiel #4
0
from command_handlers import (LaunchRequestHandler, StartLatestEpisodeHandler, StopEpisodeHandler, SearchEpisodeHandler,
                              ShuffleOnEpisodeHandler, ShuffleOffEpisodeHandler, StartOverEpisodeHandler,
                              RepeatEpisodeHandler,ResumeEpisodeHandler, HelpHandler, FallbackHandler, SessionEndedRequestHandler,
                              PreviousEpisodeHandler, NextEpisodeHandler, LoopOnEpisodeHandler, LoopOffEpisodeHandler)
from event_handlers import (PlaybackStoppedHandler, PlaybackFinishedHandler, PlaybackStartedHandler,
                            PlaybackFailedHandler, PlaybackNearlyFinishedHandler)
from interceptors import (SaveStateResponseInterceptor, LoadStateRequestInterceptor, RequestLogger, ResponseLogger,
                          CatchAllExceptionHandler)

streaming_table_name = os.getenv("STREAMING_TABLE_NAME")
skill_builder = StandardSkillBuilder(
    table_name=streaming_table_name,
    auto_create_table=False)

# Launch Request
skill_builder.add_request_handler(LaunchRequestHandler())

# Command Handlers
skill_builder.add_request_handler(StartLatestEpisodeHandler())
skill_builder.add_request_handler(SessionEndedRequestHandler())
skill_builder.add_request_handler(StopEpisodeHandler())
skill_builder.add_request_handler(ResumeEpisodeHandler())
skill_builder.add_request_handler(SearchEpisodeHandler())
skill_builder.add_request_handler(ShuffleOnEpisodeHandler())
skill_builder.add_request_handler(ShuffleOffEpisodeHandler())
skill_builder.add_request_handler(StartOverEpisodeHandler())
skill_builder.add_request_handler(RepeatEpisodeHandler())
skill_builder.add_request_handler(PreviousEpisodeHandler())
skill_builder.add_request_handler(NextEpisodeHandler())
skill_builder.add_request_handler(LoopOnEpisodeHandler())
skill_builder.add_request_handler(LoopOffEpisodeHandler())
        return True

    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        logger.error(exception, exc_info=True)
        speech_text = "Sorry, I couldn't understand what you said. Please try again."
        handler_input.response_builder.speak(speech_text).ask(
            speech_text).set_should_end_session(True)
        return handler_input.response_builder.response


# This handler acts as the entry point for your skill, routing all request and response
# payloads to the handlers above. Make sure any new handlers or interceptors you've
# defined are included below. The order matters - they're processed top to bottom.
sb = StandardSkillBuilder()
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(WithContextIntentHandler())
sb.add_request_handler(GaneshaShopIntentHandler())
sb.add_request_handler(UseIntentHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(WhatHaveIGotIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

sb.add_request_handler(BuyHandler())
sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(WhatCanIBuyHandler())
sb.add_request_handler(ProductDetailHandler())
sb.add_request_handler(RefundProductHandler())
sb.add_request_handler(CancelResponseHandler())
            found = False
            for inx, i in enumerate(existing_recipe_list):
                item = jsonpickle.decode(i)
                if item.title == cur_recipe.title:
                    existing_recipe_list[inx] = jsonpickle.encode(cur_recipe)
                    found = True
            if found == False:
                existing_recipe_list.append(session_attr[SESSION_KEY])
                persistence_attr[PERSISTENCE_KEY] = existing_recipe_list
        else:
            new_recipe_list = [session_attr[SESSION_KEY]]
            persistence_attr[PERSISTENCE_KEY] = new_recipe_list
        handler_input.attributes_manager.save_persistent_attributes()


sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

sb.add_request_handler(NewRecipeIntentHandler())
sb.add_request_handler(NewRecipeProvidedIntentHandler())
sb.add_request_handler(DeleteRecipeIntentHandler())
sb.add_request_handler(LoadRecipeIntentHandler())
sb.add_request_handler(AddIngredientCompletedIntentHandler())
sb.add_request_handler(AddIngredientInProgressIntentHandler())
sb.add_request_handler(ReadRecipeIntentHandler())

sb.add_exception_handler(AllExceptionHandler())

handler = sb.lambda_handler()
Beispiel #7
0
    def process(self, handler_input):
        # type: (HandlerInput) -> None
        logger.info("Request Envelope: {}".format(
            handler_input.request_envelope))


class ResponseLogger(AbstractResponseInterceptor):
    """Log the response envelope."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.info("Response: {}".format(response))


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(GetFactHandler())
sb.add_request_handler(YesHandler())
sb.add_request_handler(NoHandler())
sb.add_request_handler(GetCategoryFactHandler())
sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(CancelResponseHandler())
sb.add_request_handler(UpsellResponseHandler())
sb.add_request_handler(ShoppingHandler())
sb.add_request_handler(ProductDetailHandler())
sb.add_request_handler(BuyHandler())
sb.add_request_handler(CancelSubscriptionHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())
sb.add_request_handler(ServiceNameIntentHandler())
Beispiel #8
0
        return handler_input.response_builder.response


class AllExceptionHandler(AbstractExceptionHandler):
    def can_handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> bool
        return True

    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        # Log the exception in CloudWatch Logs
        print(exception)

        speech = "Sorry, I didn't get it. Can you please say it again!!"
        handler_input.response_builder.speak(speech).ask(CONTINUE_QUESTION)
        return handler_input.response_builder.response


sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(TopicIntentHandler())
sb.add_request_handler(EmailIntentHandler())
sb.add_request_handler(RepromptIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

sb.add_exception_handler(AllExceptionHandler())

handler = sb.lambda_handler()
import os
from ask_sdk.standard import StandardSkillBuilder
from handlers.launch_request_handler import LaunchRequestHandler

table_name = 'cactus'
if os.environ.get('AWS_LAMBDA_FUNCTION_VERSION') == '$LATEST':
    table_name = 'cactus-dev'
sb = StandardSkillBuilder(table_name=table_name, auto_create_table=True)
sb.add_request_handler(LaunchRequestHandler())

handler = sb.lambda_handler()
    in_skill_response = in_skill_product_response(handler_input)
    have_all_access = False
    if in_skill_response:
        subscription = [
            l for l in in_skill_response.in_skill_products
            if l.reference_name == "all_access"
        ]
    if is_entitled(subscription):
        have_all_access = True

    return have_all_access


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())

sb.add_request_handler(InProgressbuyelfsreindeerIntent())
sb.add_request_handler(CompletedbuyelfsreindeerIntent())
sb.add_request_handler(InProgressstatsIntent())
sb.add_request_handler(CompletedstatsIntent())

sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(UpsellResponseHandler())
sb.add_request_handler(ShoppingHandler())
sb.add_request_handler(ProductDetailHandler())
sb.add_request_handler(BuyHandler())
        handler_input.request_envelope)


class LoggingRequestInterceptor(AbstractRequestInterceptor):
    def process(self, handler_input):
        print(f"Incoming request {handler_input.request_envelope}")
        print(f"user id {get_user_id(handler_input)}")
        print(f"device id {get_device_id(handler_input)}")


class LoggingResponseInterceptor(AbstractResponseInterceptor):
    def process(self, handler_input, response):
        print(f"Response : {response}")


sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(FactNumberIntentHandler())
sb.add_request_handler(StartOverIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(StopOrCancelIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())
sb.add_request_handler(FallbackIntentHandler())

sb.add_exception_handler(AllExceptionHandler())

sb.add_global_request_interceptor(LoggingRequestInterceptor())

sb.add_global_response_interceptor(LoggingResponseInterceptor())
        return (is_intent_name("AMAZON.CancelIntent")(handler_input) or
                is_intent_name("AMAZON.StopIntent")(handler_input))

    def handle(self, handler_input):
        logger.info("In CancelOrStopIntentHandler")

        speech_text = 'わかりました。'

        handler_input.response_builder.speak(speech_text)
        return handler_input.response_builder.response

class AllExceptionHandler(AbstractExceptionHandler):
    def can_handle(self, handler_input, exception):
        return True

    def handle(self, handler_input, exception):

        # Log the exception in CloudWatch Logs
        print(exception)

        speech = "すみません、わかりませんでした。もう一度言ってください。"
        handler_input.response_builder.speak(speech).ask(speech)
        return handler_input.response_builder.response

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(InquiryIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_exception_handler(AllExceptionHandler())

handler = sb.lambda_handler()
Beispiel #13
0
    """Log the request envelope."""
    def process(self, handler_input):
        # type: (HandlerInput) -> None
        logger.info("Request Envelope: {}".format(
            handler_input.request_envelope))

class ResponseLogger(AbstractResponseInterceptor):
    """Log the response envelope."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.info("Response: {}".format(response))


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(YesHandler())
sb.add_request_handler(NoHandler())
sb.add_request_handler(RouterinformationHandler())
sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(CancelResponseHandler())
sb.add_request_handler(UpsellResponseHandler())
sb.add_request_handler(ServicesinformationHandler())
sb.add_request_handler(CreateserviceHandler())
sb.add_request_handler(DeviceinformationHandler())
sb.add_request_handler(CancelSubscriptionHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())
sb.add_request_handler(ServiceNameIntentHandler())
sb.add_request_handler(DeleteserviceIntentHandler())
Beispiel #14
0
class BookRecommendationIntentHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return is_intent_name('BookRecommendationIntent')(handler_input)

    def handle(self, handler_input):
        slots = handler_input.request_envelope.request.intent.slots
        for slot_name, current_slot in six.iteritems(slots):
            if slot_name == 'topic':
                if current_slot.value:
                    logger.info(book_catalogue)
        output_speech = 'Test'

        return handler_input.response_builder.speak(output_speech).set_card(
            SimpleCard('Planeta Recomienda', output_speech)).response


# Helper functions
def get_catalogue():
    book_catalogue_filename = 'booksList.json'
    with open(book_catalogue_filename, 'r') as book_catalogue_file:
        book_catalogue = json.load(book_catalogue_file)
    return book_catalogue


ssb.add_exception_handler(AllExceptionHandler())
ssb.add_request_handler(CancelStopIntentHandler())
ssb.add_request_handler(SessionEndedRequestHandler())
ssb.add_request_handler(LaunchRequestHandler())
ssb.add_request_handler(HelpIntentHandler())

handler = ssb.lambda_handler()
Beispiel #15
0
    try:
        with open("/tmp/entities.pickle", "rb") as f:
            entities = pickle.load(f)
    except FileNotFoundError:
        entities = []
        with open("/tmp/entities.pickle", "wb") as f:
            for route in routes:
                synonyms = route.route_title.lower().split(maxsplit=1)
                synonyms = list(filter(None, synonyms))
                bus_values_and_synonyms = EntityValueAndSynonyms(
                    value=route.route_title, synonyms=synonyms)
                bus_entity = entity.Entity(id=route.route_tag,
                                           name=bus_values_and_synonyms)
                entities.append(bus_entity)
            pickle.dump(entities, f)
    return entities


sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(SetDefaultsHandlerStart())
sb.add_request_handler(SetDefaultsHandlerInProgressRoute())
sb.add_request_handler(SetDefaultsHandlerInProgressStopName())
sb.add_request_handler(SetDefaultsHandlerInProgressStopNameDenied())
sb.add_request_handler(SetDefaultsHandlerInProgressStopNameConfirmed())
sb.add_request_handler(SetDefaultsHandlerInProgressIntentConfirmationDenied())
sb.add_request_handler(
    SetDefaultsHandlerInProgressIntentConfirmationConfirmed())
sb.add_request_handler(SetDefaultsHandlerCompleted())
sb.add_request_handler(NextBusDefaultsHandler())
lambda_handler = sb.lambda_handler()
Beispiel #16
0
            handler_input.attributes_manager.request_attributes[
                "_"] = gettext.gettext


class ResponseLogger(AbstractResponseInterceptor):
    """Log the alexa responses."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.debug("Alexa Response: {}".format(response))


# ###################################################################

# ############# REGISTER HANDLERS #####################
# Request Handlers
sb.add_request_handler(CheckAudioInterfaceHandler())
sb.add_request_handler(SkillEventHandler())
sb.add_request_handler(LaunchRequestOrPlayAudioHandler())
sb.add_request_handler(PlayCommandHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(ExceptionEncounteredHandler())
sb.add_request_handler(UnhandledIntentHandler())
sb.add_request_handler(NextOrPreviousIntentHandler())
sb.add_request_handler(NextOrPreviousCommandHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(PauseCommandHandler())
sb.add_request_handler(ResumeIntentHandler())
sb.add_request_handler(StartOverIntentHandler())
sb.add_request_handler(PlaybackStartedHandler())
sb.add_request_handler(PlaybackFinishedHandler())
sb.add_request_handler(PlaybackStoppedHandler())
Beispiel #17
0
    def handle(self, handler_input):
        logger.debug(
            f"Reason for ending session: {handler_input.request_envelope.request.reason}"
        )
        # persist_user_attributes(handler_input)
        return handler_input.response_builder.response


sb = StandardSkillBuilder(
    # table_name='whoami_user', auto_create_table=False,
    # partition_keygen=ask_sdk_dynamodb.partition_keygen.user_id_partition_keygen
)

# Add all request handlers to the skill.
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(StopIntent())
sb.add_request_handler(CancelIntent())
sb.add_request_handler(HelpIntent())
sb.add_request_handler(PreviousIntent())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())
# sb.add_request_handler(StartOverIntent())
# sb.add_request_handler(PauseIntent())
sb.add_request_handler(DownloadIntentHandler())
sb.add_request_handler(MovieTitleHandler())

# Add exception handler and request/response loggers to the skill.
sb.add_exception_handler(CatchAllExceptionHandler())
# sb.add_request_handler(ExceptionEncounteredRequestHandler())
Beispiel #18
0
        handler_input.response_builder.speak(speech_text).set_should_end_session(False) 
        return handler_input.response_builder.response  
    
    
class NoIntentHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return is_intent_name("AMAZON.NoIntent")(handler_input)

    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        speech_text = "O.K."
        handler_input.response_builder.speak(speech_text).set_should_end_session(False) 
        return handler_input.response_builder.response  
    
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(GetSpeeds())
sb.add_request_handler(GetToll())
sb.add_request_handler(GetTollHoursHandler())
sb.add_request_handler(GetDetailsHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_exception_handler(AllExceptionHandler())
sb.add_global_request_interceptor(SkillInitializer())
sb.add_request_handler(SaveTrip())
sb.add_request_handler(GetFavs())
sb.add_request_handler(ListInterchanges())
sb.add_request_handler(GetSpecificHelp())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())
Beispiel #19
0
class SavePersistenceAttributesResponseInterceptor(AbstractResponseInterceptor
                                                   ):
    """Save persistence attributes before sending response to user."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        handler_input.attributes_manager.save_persistent_attributes()


# ###################################################################

sb = StandardSkillBuilder(table_name=data.DYNAMODB_TABLE_NAME,
                          auto_create_table=True)

# ############# REGISTER HANDLERS #####################
# Request Handlers
sb.add_request_handler(CheckAudioInterfaceHandler())
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(ExceptionEncounteredHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(YesHandler())
sb.add_request_handler(NoHandler())
sb.add_request_handler(StartPlaybackHandler())
sb.add_request_handler(PlayCommandHandler())
sb.add_request_handler(NextPlaybackHandler())
sb.add_request_handler(NextCommandHandler())
sb.add_request_handler(PreviousPlaybackHandler())
sb.add_request_handler(PreviousCommandHandler())
sb.add_request_handler(PausePlaybackHandler())
sb.add_request_handler(PauseCommandHandler())
sb.add_request_handler(LoopOnHandler())
    WELCOME_MESSAGE = f'{json_res["records"][i]["fields"]["Utterance"]}'.replace("[last_squat_target]",str(attr.persistent_attributes["last_squat_target"])).replace("[next_squat_target]",str(attr.persistent_attributes["last_squat_target"]))

    attr.session_attributes.update({"responses":json_res})

    return WELCOME_MESSAGE

# The SkillBuilder object acts as the entry point for your skill, routing all request and response
# payloads to the handlers above. Make sure any new handlers or interceptors you've
# defined are included below. The order matters - they're processed top to bottom.

# Skill Builder object
sb = StandardSkillBuilder(table_name=DYNAMO_DB_TABLE_NAME, auto_create_table=True)

# Add all request handlers to the skill
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(SetFavoriteColorIntentHandler())
sb.add_request_handler(GetFavoriteColorIntentHandler())
sb.add_request_handler(KnowsHowToSquatHandler())
sb.add_request_handler(NeedsHelpToSquatHandler())
sb.add_request_handler(DoneIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
# make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers
sb.add_request_handler(IntentReflectorHandler())

# Add response interceptor to the skill.
sb.add_global_request_interceptor(RequestLogger())
sb.add_global_response_interceptor(ResponseLogger())
Beispiel #21
0
def get_count_person(persistence_attr):
    personClass = [0, 0]
    for person_id in persistence_attr:
        if 'personClass' not in persistence_attr[person_id]:
            pass
        elif 'parent' not in persistence_attr[person_id]['personClass']:
            personClass[0] += 1
        elif 'parent' not in persistence_attr[person_id]['personClass']:
            personClass[1] += 1
    return personClass


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(WishAddInIntentHandler())
sb.add_request_handler(WishListIntentHandler())
sb.add_request_handler(WishDeleteIntentHandler())
sb.add_request_handler(AnswerClassIntentHandler())
sb.add_request_handler(PremiumInfoIntentHandler())
sb.add_request_handler(ShoppingIntentHandler())
sb.add_request_handler(BuyIntentHandler())
sb.add_request_handler(CancelSubscriptionIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelIntentHandler())
sb.add_request_handler(StopIntentHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(BuyResponseHandler())
from handlers.upsell_response_handler import UpsellResponseHandler
from handlers.cancel_subscription_handler import CancelSubscriptionHandler
from handlers.cancel_response_handler import CancelResponseHandler
from handlers.yes_intent_handler import YesIntentHandler
from handlers.no_intent_handler import NoIntentHandler
from handlers.help_intent_handler import HelpIntentHandler
from handlers.cancel_or_stop_intent_handler import CancelOrStopIntentHandler
from handlers.session_ended_request_handler import SessionEndedRequestHandler
from handlers.catch_all_exception_handler import CatchAllExceptionHandler

table_name = 'cactus'
if os.environ.get('AWS_LAMBDA_FUNCTION_VERSION') == '$LATEST':
    table_name = 'cactus-dev'
sb = StandardSkillBuilder(table_name=table_name, auto_create_table=True)

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(CancelResponseHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())

# ISP
sb.add_request_handler(BuyHandler())
sb.add_request_handler(BuyResponseHandler())
sb.add_request_handler(UpsellResponseHandler())
sb.add_request_handler(CancelSubscriptionHandler())

sb.add_exception_handler(CatchAllExceptionHandler())
        return handler_input.response_builder.response


class RequestLogger(AbstractRequestInterceptor):
    """Log the request envelope."""
    def process(self, handler_input):
        # type: (HandlerInput) -> None
        logger.info("Request Envelope: {}".format(
            handler_input.request_envelope))


class ResponseLogger(AbstractResponseInterceptor):
    """Log the response envelope."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.info("Response: {}".format(response))


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())
sb.add_exception_handler(CatchAllExceptionHandler())
sb.add_global_request_interceptor(RequestLogger())
sb.add_global_response_interceptor(ResponseLogger())

lambda_handler = sb.lambda_handler()

#End of program
Beispiel #24
0
        Args:
            handler_input (ask_sdk_core.handler_input.HandlerInput): The input from Alexa.

        Returns:
            ask_sdk_model.response.Response: Response for this intent and device.

        """
        speeches = ["Sure. Whatever. ", "Of course. ", "Canceling. "]
        speech = random.choice(speeches)

        responseBuilder = handler_input.response_builder
        responseBuilder.speak(speech).ask(speech)
        responseBuilder.set_should_end_session(True)
        return handler_input.response_builder.response


# =============================================================================
# SKILL BUILDER
# =============================================================================
sb = StandardSkillBuilder()
# Monetization:
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(BuyProductIntentHandler())
sb.add_request_handler(CancelProductIntentHandler())
# Standard:
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

handler = sb.lambda_handler()
Beispiel #25
0
from ask_sdk.standard import StandardSkillBuilder

from fallzahlen.handlers.today_handler import TodayIntentHandler
from fallzahlen.handlers.close_handler import CloseRequestHandler
from fallzahlen.handlers.help_handler import HelpHandler
from fallzahlen.handlers.fallback_handler import FallbackHandler
from fallzahlen.handlers.exception_handler import ExceptionHandler

builder = StandardSkillBuilder()
builder.add_request_handler(TodayIntentHandler())
builder.add_request_handler(CloseRequestHandler())
builder.add_request_handler(HelpHandler())
builder.add_request_handler(FallbackHandler())
builder.add_exception_handler(ExceptionHandler())

handler = builder.lambda_handler()
Beispiel #26
0
    This handler catches all kinds of exceptions and prints
    the stack trace on AWS Cloudwatch with the request envelope.
    """

    def can_handle(self, handler_input, exception):
        """Can handle or not."""
        return True

    def handle(self, handler_input, exception):
        """Handle response."""
        logger.error(exception, exc_info=True)
        request = handler_input.request_envelope.request
        logger.info(f"Original request was {request}")
        speech = "Sorry, there was a problem. Please try again!!"
        handler_input.response_builder.speak(speech).ask(speech)
        return handler_input.response_builder.response


# Add all request handlers to the skill.
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(PhoneNumberIntentHandler())
sb.add_request_handler(ExitIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

# Add exception handler to the skill.
sb.add_exception_handler(CatchAllExceptionHandler())

# Expose the lambda handler to register in AWS Lambda.
lambda_handler = sb.lambda_handler()
Beispiel #27
0
    #speech = "Welcome to Saint Kilian Parish, Mission Viejo. "
    speech = "<speak>"
    speech += '<audio src="https://st-killian-resources.s3.amazonaws.com/killianWelcome01_ssml.mp3"></audio> '  # pylint: disable=C0301
    speech += "How may I be of service?"
    speech += "</speak>"
    reprompt = "Try asking: when is the next Mass."
    title = "St. Kilian Parish, Mission Viejo"
    text = "Try asking 'When is the next mass?'"
    cardImage = None
    return speech, reprompt, title, text, cardImage


# =============================================================================
# Skill Builder
# =============================================================================
sb.add_request_handler(AudioNextIntentHandler())
sb.add_request_handler(AudioPlaybackFinishedHandler())
sb.add_request_handler(AudioPlaybackNearlyFinishedHandler())
sb.add_request_handler(AudioPlaybackStartedHandler())
sb.add_request_handler(AudioPlaybackStoppedHandler())
sb.add_request_handler(AudioPreviousIntentHandler())
sb.add_request_handler(AudioResumeIntentHandler())
sb.add_request_handler(AudioStartOverIntentHandler())
sb.add_request_handler(AudioStopIntentHandler())
sb.add_request_handler(AudioUnsupportedHandler())

sb.add_request_handler(CalendarEventHandler())
sb.add_request_handler(ConfessionHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(HelpIntentHandler())
Beispiel #28
0
    def process(self, handler_input):
        logger.info("Request Envelope: {}".format(
            handler_input.request_envelope))


class ResponseLogger(AbstractResponseInterceptor):
    """Log the response envelope."""
    def process(self, handler_input, response):
        logger.info("Response: {}".format(response))


# build a skill
sb = StandardSkillBuilder(table_name="Pomodoro", auto_create_table=True)

# add request handlers
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(PomodoroSessionHandler())
sb.add_request_handler(StartBreakHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelAndStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

# add exception handler
sb.add_exception_handler(AllExceptionHandler())

# add response interceptor
sb.add_global_request_interceptor(RequestLogger())
sb.add_global_response_interceptor(ResponseLogger())

# expose the lambda handler to register in AWS Lambda
lambda_handler = sb.lambda_handler()
Beispiel #29
0
    def process(self, handler_input):
        # type: (HandlerInput) -> None
        logger.info("Request Envelope: {}".format(
            handler_input.request_envelope))


class ResponseLogger(AbstractResponseInterceptor):
    """Log the response envelope."""
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        logger.info("Response: {}".format(response))


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(InProgressHowMuchIntent())
sb.add_request_handler(InProgressHowManyIntent())
sb.add_request_handler(HowMuchIsCryptoInFiat())
sb.add_request_handler(HowManyCryptoCanIBuy())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())
sb.add_request_handler(RepeatHandler())
sb.add_exception_handler(CatchAllExceptionHandler())
sb.add_global_request_interceptor(RequestLogger())
sb.add_global_response_interceptor(ResponseLogger())

lambda_handler = sb.lambda_handler()

#End of program
Beispiel #30
0
    except:
        stats = {}

    return stats


def have_all_access(handler_input):
    in_skill_response = in_skill_product_response(handler_input)
    have_all_access = False
    if in_skill_response:
        subscription = [
            l for l in in_skill_response.in_skill_products
            if l.reference_name == "all_access"
        ]
    if is_entitled(subscription):
        have_all_access = True

    return have_all_access


sb = StandardSkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedHandler())

sb.add_request_handler(InProgressbuyelfsreindeerIntent())
sb.add_request_handler(CompletedbuyelfsreindeerIntent())
sb.add_request_handler(InProgressstatsIntent())
sb