예제 #1
0
    def test_custom_persistence_adapter_default_null(self):
        test_custom_skill_builder = CustomSkillBuilder()

        actual_skill_config = test_custom_skill_builder.skill_configuration

        assert actual_skill_config.persistence_adapter is None, (
            "Custom Skill Builder didn't set the default persistence adapter "
            "as None")
예제 #2
0
    def test_custom_api_client_default_null(self):
        test_custom_skill_builder = CustomSkillBuilder()

        actual_skill_config = test_custom_skill_builder.skill_configuration

        assert actual_skill_config.api_client is None, (
            "Custom Skill Builder didn't set the default api client "
            "as None")
예제 #3
0
    def test_custom_api_client_used(self):
        mock_api_client = mock.Mock()
        test_custom_skill_builder = CustomSkillBuilder(
            api_client=mock_api_client)

        actual_skill_config = test_custom_skill_builder.skill_configuration

        assert actual_skill_config.api_client == mock_api_client, (
            "Custom Skill Builder didn't set the api client provided")
예제 #4
0
    def test_custom_persistence_adapter_used(self):
        mock_adapter = mock.Mock()
        test_custom_skill_builder = CustomSkillBuilder(
            persistence_adapter=mock_adapter)

        actual_skill_config = test_custom_skill_builder.skill_configuration

        assert actual_skill_config.persistence_adapter == mock_adapter, (
            "Custom Skill Builder didn't set the persistence adapter provided")
예제 #5
0
import json
import prompts
import recipe_utils
import apl_utils

from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.serialize import DefaultSerializer
from ask_sdk_core.dispatch_components import (AbstractRequestHandler,
                                              AbstractExceptionHandler,
                                              AbstractResponseInterceptor,
                                              AbstractRequestInterceptor)
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_model.ui import StandardCard, Image
from ask_sdk_model import Response

sb = CustomSkillBuilder()

logger = logging.getLogger("main")
logger.setLevel(logging.INFO)


class LaunchRequestIntentHandler(AbstractRequestHandler):
    """
    Handles LaunchRequest requests sent by Alexa
    Note: this type of request is sent when hte user invokes your skill without providing a specific intent
    """
    def can_handle(self, handler_input):
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        data = handler_input.attributes_manager.request_attributes["_"]
예제 #6
0
import logging

from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model import Response
from ask_sdk_model.ui import SimpleCard, AskForPermissionsConsentCard
from ask_sdk_model.services import ServiceException
# python standard library
import json
# third party
import requests
import xmltodict

sb = CustomSkillBuilder(api_client=DefaultApiClient()) # remove api client

#logger = logging.getLogger(__name__)
#logger.setLevel(logging.INFO)
permissions = ["read::alexa:device:all:address"]

Subway_LIST = ["1", "2", "3", "4", "5", "6", "7", "a", "c", "e", "f", "b", "n", "r", "q", "m", "s", "j", "z", "d", "g","l"]

Subway_Status = {"1":"", "2":"", "3":"", "4":"", "5":"", "6":"", "7":"", "a":"", "c":"", "e":"", "f":"", "b":"", "n":"", "r":"",
                    "q":"", "w":"", "m":"", "s":"", "j":"", "z":"", "d":"", "g":"","l":"", "si":""}

WELCOME = ("Welcome to the Sample Device Address API Skill!  "
           "You can ask for the device address by saying what is my "
           "address.  What do you want to ask?")
WHAT_DO_YOU_WANT = "What do you want to ask?"
NOTIFY_MISSING_PERMISSIONS = ("Please enable Location permissions in "
예제 #7
0
from ask_sdk_core.skill_builder import SkillBuilder
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model.services.directive import (
    SendDirectiveRequest, Header, SpeakDirective)

from ask_sdk_model.ui import SimpleCard
from ask_sdk_model import Response

from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.skill_builder import CustomSkillBuilder

sb = CustomSkillBuilder(api_client=DefaultApiClient())

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


URL = 'http://35.197.194.231:5000/authenticate/'
headers = "Content-Type: application/json"


#globals for flow control
fact_number = None
fact_name = None
transaction_completed = False

def check_auth(json):
        return True

    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        logger.error(exception, exc_info=True)

        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)


# 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.

sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(RodarRoletaIntentHandler())
sb.add_request_handler(CriarRoletaIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(
    IntentReflectorHandler()
)  # make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers

sb.add_exception_handler(CatchAllExceptionHandler())

lambda_handler = sb.lambda_handler()
        return False


def is_warning_needed(current_wealth, current_energy):
    if current_wealth <= 10 or current_energy <= 10:
        return True
    else:
        return False


# 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 = CustomSkillBuilder(api_client=DefaultApiClient())

# Add all request handlers to the skill.
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(StartAdventureIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())

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

# Add request and response interceptors
예제 #10
0
        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
        )

# 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.
try:
    s3_adapter = S3Adapter(bucket_name=AWS_S3_BUCKET)

    sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

    sb.add_request_handler(LaunchRequestHandler())

    sb.add_request_handler(SetRoomIntentHandler())
    sb.add_request_handler(PauseIntentHandler())
    sb.add_request_handler(PlayIntentHandler())
    sb.add_request_handler(StopIntentHandler())
    sb.add_request_handler(SetVolumeIntentHandler())
    sb.add_request_handler(PreviousIntentHandler())
    sb.add_request_handler(NextIntentHandler())

    sb.add_request_handler(RestartIntentHandler())
    sb.add_request_handler(PlayTrailerIntentHandler())
    sb.add_request_handler(PlayOnAppIntentHandler())
예제 #11
0
# -*- coding: utf-8 -*-

from ask_sdk_core.skill_builder import CustomSkillBuilder

from handlers import *
import utils

# 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.
sb = CustomSkillBuilder(persistence_adapter=utils.s3_adapter())

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(RegisterPressureIntentHandler())
sb.add_request_handler(ReadLastPressureIntentHandler())
sb.add_request_handler(RemoveLastPressureIntentHandler())
sb.add_request_handler(EditLastPressureIntentHandler())
sb.add_request_handler(ReportLatestPressuresIntentHandler())
sb.add_request_handler(AddReminderIntentHandler())
# sb.add_request_handler(RemoveReminderIntentHandler())
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())

sb.add_exception_handler(CatchAllExceptionHandler())

lambda_handler = sb.lambda_handler()
from datetime import datetime
from pytz import timezone
import gettext

from alexa import data

from ask_sdk_s3.adapter import S3Adapter
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.dispatch_components import (AbstractRequestHandler,
                                              AbstractExceptionHandler,
                                              AbstractRequestInterceptor,
                                              AbstractResponseInterceptor)
from ask_sdk_core.utils import is_request_type, is_intent_name

s3_adapter = S3Adapter(bucket_name="custom-walk-testing")
sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

logger = logging.getLogger("main")
logger.setLevel(logging.INFO)


class LaunchRequestIntentHandler(AbstractRequestHandler):
    """
    Handler for Skill Launch
    """
    def can_handle(self, handler_input):
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        _ = handler_input.attributes_manager.request_attributes["_"]
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_model.ui import SimpleCard
from ask_sdk_model.services.directive import (SendDirectiveRequest, Header,
                                              SpeakDirective)
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model.response import Response
import time
import logging

sb = CustomSkillBuilder(api_client=DefaultApiClient())
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class LaunchRequestHandler(AbstractRequestHandler):
    # Handler for Skill Launch
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        speech_text = "Welcome to the Alexa Skills Kit, you can say hello!"

        handler_input.response_builder.speak(speech_text).set_card(
            SimpleCard("Hello World",
                       speech_text)).set_should_end_session(False)
예제 #14
0
import requests
import json
import config
import utils
import language
import trakt_api

from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.utils import is_request_type, is_intent_name, get_slot_value
from ask_sdk_core.handler_input import HandlerInput  # noqa: F401
from ask_sdk_model import Response  # noqa: F401
from ask_sdk_s3.adapter import S3Adapter
from datetime import datetime

s3_adapter = S3Adapter(bucket_name=os.environ["S3_PERSISTENCE_BUCKET"])
sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

watch_lists = ('watchlist', 'watch list')
DATE_FORMAT = '%Y-%m-%d'
clientid = config.client_id
user = '******'
is_auth = False


@sb.request_handler(can_handle_func=lambda input: is_request_type("LaunchRequest")(input)
                    or is_intent_name("AddMovie")(input))
def add_movie_intent_handler(handler_input):
    """Handler for Add Movie Intent."""
예제 #15
0
class RepeatInterceptor(AbstractResponseInterceptor):

    def process(self, handler_input, response):
        session_attributes = handler_input.attributes_manager.session_attributes
        session_attributes["repeat_speech_output"] = response.output_speech.ssml.replace("<speak>","").replace("</speak>","")
        try:
            session_attributes["repeat_reprompt"] = response.reprompt.output_speech.ssml.replace("<speak>","").replace("</speak>","")
        except:
            session_attributes["repeat_reprompt"] = response.output_speech.ssml.replace("<speak>","").replace("</speak>","")


# Skill Builder
# Define a skill builder instance and add all the request handlers,
# exception handlers and interceptors to it.

sb = CustomSkillBuilder (persistence_adapter = s3_adapter)
sb.add_request_handler(InvalidConfigHandler())
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(MyNameIsIntentHandler())
sb.add_request_handler(LearnMoreIntentHandler())
sb.add_request_handler(YesNoIntentHandler())
sb.add_request_handler(RepeatIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(FallbackIntentHandler())
sb.add_request_handler(SessionEndedRequesthandler())

sb.add_exception_handler(CatchAllExceptionHandler())

sb.add_global_request_interceptor(LocalizationInterceptor())
sb.add_global_request_interceptor(InvalidConfigInterceptor())
예제 #16
0
    """Log the request envelope."""
    def process(self, handler_input):
        # type: (HandlerInput) -> None
        logger.info('Request recieved: {}'.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 generated: {}'.format(response))


# Skillbuilder
sb = CustomSkillBuilder(api_client=DefaultApiClient())

# Custom
sb.add_request_handler(createWorkoutAPIHandler())
sb.add_request_handler(GetRecommendationAPIHandler())
sb.add_request_handler(GetDescriptionAPIHandler())

# Standard
sb.add_request_handler(SessionEndedRequestHandler())

# Exceptions
sb.add_exception_handler(CatchAllExceptionHandler())

# Loggers
sb.add_global_request_interceptor(RequestLogger())
sb.add_global_response_interceptor(ResponseLogger())
from flask import Flask
from flask_ask_sdk.skill_adapter import SkillAdapter

import Utils
import data

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

user_slot = "userName"
medicine_slot = "medicine"
REQUIRED_PERMISSIONS = ["alexa::alerts:reminders:skill:readwrite"]
TIME_ZONE_ID = "Asia/Kolkata"

app = Flask(__name__)
sb = CustomSkillBuilder(api_client=DefaultApiClient())


class LaunchRequestHandler(AbstractRequestHandler):
    """Launch Request Handler"""
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return ask_utils.is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        _ = handler_input.attributes_manager.request_attributes["_"]
        speak_output = data.launch_welcome_message

        return (handler_input.response_builder.speak(speak_output).response)
예제 #18
0
"""Generic error handling to capture any syntax or routing errors. If you receive an error stating the request handler chain is 
not found, you have not implemented a handler for the intent being invoked or included it in the skill builder below."""
class CatchAllExceptionHandler(AbstractExceptionHandler):
    def can_handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> bool
        return True

    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        logger.error(exception, exc_info=True)
        return handler_input.response_builder.speak(data.ISSUE_MESSAGE).ask(data.ISSUE_MESSAGE).response

#Processed top to bottom

sb = CustomSkillBuilder(persistence_adapter=s3_adapter)#SkillBuilder()

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(CaptureQuestionTypeIntentHandler())
sb.add_request_handler(RepeatQIntentHandler())
sb.add_request_handler(GetAnswerIntentHandler())
sb.add_request_handler(CaptureUserAnswerIntent())
#sb.add_request_handler(CaptureGradeLevelIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(IntentReflectorHandler()) # make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers

sb.add_exception_handler(CatchAllExceptionHandler())

lambda_handler = sb.lambda_handler()
예제 #19
0
            language_data = json.load(language_prompts)
        # set default translation data to broader translation
        data = language_data[skill_locale[:2]]
        # if a more specialized translation exists, then select it instead
        # example: "fr-CA" will pick "fr" translations first, but if "fr-CA" translation exists,
        #          then pick that instead
        if skill_locale in language_data:
            data.update(language_data[skill_locale])
        handler_input.attributes_manager.request_attributes["_"] = data

        # configure the runtime to treat time according to the skill locale
        skill_locale = skill_locale.replace('-', '_')
        locale.setlocale(locale.LC_TIME, skill_locale)


sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(MeditationIntentHandler())
sb.add_request_handler(MedicationIntentHandler())
sb.add_request_handler(CheckMedicationIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(PanicAttackIntentHandler())
sb.add_request_handler(YesIntentHandler())
sb.add_request_handler(NoIntentHandler())
sb.add_request_handler(ResourcesIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(
    IntentReflectorHandler()
)  # make sure IntentReflectorHandler is last so it doesn’t override your custom intent handlers
예제 #20
0
    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        logger.error(exception, exc_info=True)
        
        return (
            handler_input.response_builder
            .speak("Uh Oh. Looks like something went wrong.")
            .ask("Uh Oh. Looks like something went wrong.")
            .response
        )

# 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.

sb = CustomSkillBuilder(api_client=DefaultApiClient())

sb.add_request_handler(LaunchRequestHandler())

sb.add_request_handler(TimerIntentHandler())
sb.add_request_handler(AcceptGrantResponseHandler())
sb.add_request_handler(ConnectionsResponsehandler())
sb.add_request_handler(SessionResumedHandlerRequest())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())

# Adding Request and Response interceptor
sb.add_global_request_interceptor(LoggingRequestInterceptor())
sb.add_global_response_interceptor(LoggingResponseInterceptor())

handler = sb.lambda_handler()
예제 #21
0
from ask_sdk_model.interfaces.display import (ImageInstance, Image,
                                              RenderTemplateDirective,
                                              ListTemplate1,
                                              BackButtonBehavior, ListItem,
                                              BodyTemplate2, BodyTemplate1)
from ask_sdk_model import ui, Response, DialogState
from ask_sdk_model.ui import SimpleCard
from ask_sdk_model.dialog import ElicitSlotDirective, DelegateDirective
from ask_sdk_model import (Intent, IntentConfirmationStatus, Slot,
                           SlotConfirmationStatus)
from ask_sdk_model.slu.entityresolution.resolution import Resolution
from ask_sdk_model.slu.entityresolution import StatusCode

from alexa import data, util

sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

# Set the skill id so not just anyone can invoke this function
sb.skill_id = "amzn1.ask.skill.92878a4c-6715-4eed-9b71-7805480315a0"

gravIntent = Intent()
calIntent = Intent(name="CalibrateIntent")

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class LaunchRequestHandler(AbstractRequestHandler):
    """Determine if this is a Launch Request."""
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
예제 #22
0
        logger.debug("Alexa Response: {}".format(response))

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()

# ###################################################################
# 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.


s3_adapter = S3Adapter(bucket_name=os.environ["S3_PERSISTENCE_BUCKET"])
sb = CustomSkillBuilder(persistence_adapter=s3_adapter,api_client=DefaultApiClient())

# ############# 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(TodayIntentHandler())
sb.add_request_handler(playAudioIntentHandler())
sb.add_request_handler(qayaamIntentHandler())
sb.add_request_handler(rozaNiyatIntentHandler())
sb.add_request_handler(moharramIntentHandler())
sb.add_request_handler(NamaazTimesIntentHandler())
예제 #23
0
import logging
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.dispatch_components import AbstractResponseInterceptor
from ask_sdk_core.dispatch_components import AbstractRequestInterceptor
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model import Response
from ask_sdk_core.exceptions import AskSdkException
import ask_sdk_core.utils as ask_utils

from handlers.exports import request_handlers
from interceptors import LoggingRequestInterceptor, LoggingResponseInterceptor
from handlers.core.errorhandlers import CatchAllExceptionHandler

sb = CustomSkillBuilder(api_client=DefaultApiClient())

for h in request_handlers:
    sb.add_request_handler(h)

sb.add_exception_handler(CatchAllExceptionHandler())
sb.add_global_response_interceptor(LoggingResponseInterceptor())
sb.add_global_request_interceptor(LoggingRequestInterceptor())

# This is the exported entry point.
lambda_handler = sb.lambda_handler()
from ask_sdk_dynamodb.adapter import DynamoDbAdapter
from ask_sdk_dynamodb.adapter import DynamoDbAdapter

from ask_sdk_model import Response

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

ddb_region = os.environ.get('DYNAMODB_PERSISTENCE_REGION')
ddb_table_name = os.environ.get('DYNAMODB_PERSISTENCE_TABLE_NAME')
ddb_resource = boto3.resource('dynamodb', region_name=ddb_region)
dynamodb_adapter = DynamoDbAdapter(table_name=ddb_table_name,
                                   create_table=False,
                                   dynamodb_resource=ddb_resource)
sb = CustomSkillBuilder(persistence_adapter=dynamodb_adapter)

TOKEN = "Removed Upon Request"
USER = "******"


class PromptQuestionHandler(AbstractRequestHandler):
    """Handler for Skill Launch and PromptQuestion Intent."""
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return (is_request_type("LaunchRequest")(handler_input)
                or is_intent_name("PromptQuestion")(handler_input))

    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In PromptQuestionHandler")
예제 #25
0
        # type: (HandlerInput, Exception) -> bool
        return True

    def handle(self, handler_input, exception):
        # type: (HandlerInput, Exception) -> Response
        logger.error(exception, exc_info=True)

        speak_output = "すみません、何か上手くいかないみたいです。もう一度試してください。"

        return (handler_input.response_builder.speak(speak_output).ask(
            speak_output).response)


sb = SkillBuilder()

#sb = CustomSkillBuilder(persistence_adapter = s3_adapter)
sb = CustomSkillBuilder(persistence_adapter=dynamodb_adapter)

sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(DiapersNoteIntentHandler())
sb.add_request_handler(InitialDiaperIntentHandler())
sb.add_request_handler(HelpIntentHandler())
sb.add_request_handler(CancelOrStopIntentHandler())
sb.add_request_handler(SessionEndedRequestHandler())
sb.add_request_handler(
    IntentReflectorHandler()
)  # make sure IntentReflectorHandler is last so it doesn't override your custom intent handlers

sb.add_exception_handler(CatchAllExceptionHandler())

lambda_handler = sb.lambda_handler()
예제 #26
0
# session persistence, api calls, and more.

import requests
import logging
import calendar
from datetime import datetime
from pytz import timezone

from ask_sdk_s3.adapter import S3Adapter
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.dispatch_components import (AbstractRequestHandler,
                                              AbstractExceptionHandler)
from ask_sdk_core.utils import is_request_type, is_intent_name

s3_adapter = S3Adapter(bucket_name="custom-walk-testing")
sb = CustomSkillBuilder(persistence_adapter=s3_adapter)

logger = logging.getLogger("main")
logger.setLevel(logging.INFO)


class LaunchRequestIntentHandler(AbstractRequestHandler):
    """
    Handler for Skill Launch
    """
    def can_handle(self, handler_input):
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        speech = "Hello! Welcome to Cake Time. What is your birthday?"
        reprompt = "I was born Nov. 6th, 2015. When were you born?"
예제 #27
0
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_model.ui import SimpleCard
from ask_sdk_model.ui import AskForPermissionsConsentCard
from ask_sdk_model import Response
from ask_sdk_model.permission_status import PermissionStatus
from ask_sdk_model.services.service_exception import ServiceException
from ask_sdk_model.canfulfill import CanFulfillIntent, CanFulfillIntentValues

if getenv("ENVIRONMENT") in (None, "PROD"):
    aws_lambda_logging.setup(level="INFO")
else:
    logging.basicConfig(level=logging.INFO)

sb = CustomSkillBuilder(api_client=DefaultApiClient())

ERROR_TITLE = "Uh oh"
ERROR = "Looks like something went wrong."
NOTIFY_TITLE = "Permissions needed"
NOTIFY_MISSING_ADDRESS_PERMISSIONS = ("Please enable Address permissions in "
                                      "the Amazon Alexa app.")
NOTIFY_MISSING_LOCATION_PERMISSIONS = ("Please enable Location permissions in "
                                       "the Amazon Alexa app.")

SWEET_TITLE = "Your Air Report"

SWEET_CARD = ("I found an {}air sensor that's {} away. "
              "The air quality is {}. "
              "Your AQI is {}.")
SWEET_SPEECH = (
예제 #28
0
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from metro_api.directions_api import get_train
from metro_api import commands
from ask_sdk_model import Response
from ask_sdk_model.slu.entityresolution import StatusCode
from ask_sdk_model.ui import SimpleCard, AskForPermissionsConsentCard
from ask_sdk_model.services.reminder_management import Trigger, TriggerType, AlertInfo, SpokenInfo, SpokenText, \
    PushNotification, PushNotificationStatus, ReminderRequest
from ask_sdk_model.services import ServiceException
import pytz
from datetime import datetime

sb = CustomSkillBuilder(
    api_client=DefaultApiClient())  # required to use remiders

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
REQUIRED_PERMISSIONS = [
    "alexa::alerts:reminders:skill:readwrite", "read::alexa:device:all:address"
]


# Request Handler classes
class LaunchRequestHandler(AbstractRequestHandler):
    """Handler for skill launch."""
    def can_handle(self, handler_input):
        # type: (HandlerInput) -> bool
        return is_request_type("LaunchRequest")(handler_input)
예제 #29
0
            with open("languages/" + str(locale) + ".json") as language_data:
                language_prompts = json.load(language_data)
        except:
            with open("languages/" + str(locale[:2]) +
                      ".json") as language_data:
                language_prompts = json.load(language_data)

        handler_input.attributes_manager.request_attributes[
            "_"] = language_prompts


# Skill Builder
# Define a skill builder instance and add all the request handlers,
# exception handlers and interceptors to it.

sb = CustomSkillBuilder(persistence_adapter=dynamodb_adapter)
sb.add_request_handler(CheckAudioInterfaceHandler())
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(PlayNewestEpisodeIntentHandler())
sb.add_request_handler(PlayOldestEpisodeIntentHandler())
sb.add_request_handler(ChooseEpisodeIntentHandler())
sb.add_request_handler(PauseIntentHandler())
sb.add_request_handler(ResumeIntentHandler())
sb.add_request_handler(NoIntentHandler())
sb.add_request_handler(NextIntentHandler())
sb.add_request_handler(PreviousIntentHandler())
sb.add_request_handler(RepeatIntentHandler())
sb.add_request_handler(ShuffleOnIntentHandler())
sb.add_request_handler(ShuffleOffIntentHandler())
sb.add_request_handler(LoopOnIntentHandler())
sb.add_request_handler(LoopOffIntentHandler())
예제 #30
0
from config import settings
from handlers import game_play_handlers, global_handlers, start_handlers, roll_call_handlers

ENV = os.environ.get('ENV')
adapter_config = {
    "table_name": settings.STORAGE['session_table'],
    "create_table": ENV == 'DEV',
}
if ENV == 'DEV':
    localhost = 'http://localhost:8000'
    adapter_config["dynamodb_resource"] = boto3.resource("dynamodb", endpoint_url=localhost)
else:
    adapter_config["dynamodb_resource"] = boto3.resource("dynamodb")


sb = CustomSkillBuilder(persistence_adapter=DynamoDbAdapter(**adapter_config))
sb.skill_id = settings.APP_ID

sb.add_request_handler(game_play_handlers.AnswerHandler())
sb.add_request_handler(game_play_handlers.DontKnowNextHandler())
sb.add_request_handler(game_play_handlers.GameEventHandler())
sb.add_request_handler(game_play_handlers.PlayGameHandler())
sb.add_request_handler(game_play_handlers.EndGameHandler())
sb.add_request_handler(game_play_handlers.YesHandler())
sb.add_request_handler(roll_call_handlers.YesHandler())
sb.add_request_handler(roll_call_handlers.NoHandler())
sb.add_request_handler(roll_call_handlers.GameEventHandler())
sb.add_request_handler(start_handlers.PlayerCountHandler())
sb.add_request_handler(start_handlers.YesHandler())
sb.add_request_handler(start_handlers.NoHandler())
sb.add_request_handler(start_handlers.LaunchPlayGameHandler())