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()
Ejemplo n.º 2
0
    def test_persistence_adapter_set(self):
        test_table_name = "TestTable"
        test_dynamodb_resource = mock.Mock()
        test_partition_keygen = mock.Mock()
        test_auto_create_table = False

        test_skill_builder = StandardSkillBuilder(
            table_name=test_table_name,
            auto_create_table=test_auto_create_table,
            partition_keygen=test_partition_keygen,
            dynamodb_client=test_dynamodb_resource)

        actual_skill_config = test_skill_builder.skill_configuration
        actual_adapter = actual_skill_config.persistence_adapter

        assert isinstance(actual_adapter, DynamoDbAdapter), (
            "Standard Skill Builder set incorrect persistence adapter in "
            "skill configuration")

        assert actual_adapter.table_name == test_table_name, (
            "Standard Skill Builder set persistence adapter with incorrect "
            "table name in skill configuration")
        assert actual_adapter.partition_keygen == test_partition_keygen, (
            "Standard Skill Builder set persistence adapter with incorrect "
            "partition key generator function in skill configuration")
        assert actual_adapter.create_table == test_auto_create_table, (
            "Standard Skill Builder set persistence adapter with incorrect "
            "auto create table flag in skill configuration")
        assert actual_adapter.dynamodb == test_dynamodb_resource, (
            "Standard Skill Builder set persistence adapter with incorrect "
            "dynamo db resource in skill configuration")
Ejemplo n.º 3
0
    def test_persistence_adapter_default_null(self):
        test_skill_builder = StandardSkillBuilder()

        actual_skill_config = test_skill_builder.skill_configuration

        assert actual_skill_config.persistence_adapter is None, (
            "Standard Skill Builder didn't set Persistence Adapter to None "
            "when no table_name is provided")
Ejemplo n.º 4
0
    def test_default_api_client_set(self):
        test_skill_builder = StandardSkillBuilder()

        actual_skill_config = test_skill_builder.skill_configuration

        assert isinstance(actual_skill_config.api_client, DefaultApiClient), (
            "Standard Skill Builder didn't set the api client to the default"
            "implementation")
Ejemplo n.º 5
0
#point at local dynamodb
#skill_persistence_table = os.environ["skill_persistence_table"]
skill_persistence_table = 'recipedb'
dynamodb = boto3.resource(
    'dynamodb',
    region_name='us-east-1')  #, endpoint_url="http://localhost:8000")

RECIPE_SLOT = 'recipe'
INGREDIENT_SLOT = 'ingredient'
SESSION_KEY = 'current_recipe'
PERSISTENCE_KEY = 'recipe_list'

sb = StandardSkillBuilder(table_name=skill_persistence_table,
                          auto_create_table=False,
                          partition_keygen=ask_sdk_dynamodb.partition_keygen.
                          user_id_partition_keygen,
                          dynamodb_client=dynamodb)


class LaunchRequestHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        speech_text = "Welcome to the Recipe Tracker Skill. Say 'start a recipe' or 'create a recipe' to start tracking!"

        handler_input.response_builder.speak(speech_text).set_card(
            SimpleCard("Launch Recipe Tracker",
                       speech_text)).set_should_end_session(False)
        return handler_input.response_builder.response
# coding: UTF-8
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_model.ui import SimpleCard
from ask_sdk_core.response_helper import ResponseFactory
from ask_sdk.standard import StandardSkillBuilder
import datetime
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamodb = boto3.resource('dynamodb', region_name='ap-northeast-1')
table = dynamodb.Table('SapporoTrashCalendar')

sb = StandardSkillBuilder(table_name="SapporoTrash", auto_create_table=True)


class LaunchRequestHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return handler_input.request_envelope.request.object_type == "LaunchRequest"

    def handle(self, handler_input):
        attr = handler_input.attributes_manager.persistent_attributes
        if not attr:
            speech_text = "札幌市のゴミ収集情報をお知らせします。はじめに、収集エリアの設定を行います。おすまいの区を教えてください"
            card_title = "初期設定"
            card_body = "お住いの区を教えてください"
            reprompt = "おすまいの区を教えてください"
        else:
            speech_text = "今日以降で何のゴミか知りたい日、または、出したいゴミの種類、どちらかを教えてください"
            reprompt = "今日以降で何のゴミか知りたい日、または、出したいゴミの種類、どちらかを教えてください"
Ejemplo n.º 7
0
"""lambda_function.py: example phone Alexa skill."""
import logging

from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.dispatch_components import (
    AbstractRequestHandler, AbstractExceptionHandler)
from ask_sdk_core.utils import is_intent_name, is_request_type

sb = StandardSkillBuilder(table_name="PhoneTable", auto_create_table=True)

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


class LaunchRequestHandler(AbstractRequestHandler):
    """Handler for skill launch."""

    def can_handle(self, handler_input):
        """Can handle or not."""
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        """Handle response."""
        logger.info("In LaunchRequestHandler")
        # get attributes from DynamoDB table
        session_attr = handler_input.attributes_manager.persistent_attributes
        if not session_attr:
            # first time
            speech = "Hi. What is your phone number?"
            reprompt = "What is your phone number?"
        else:
Ejemplo n.º 8
0
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(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()
Ejemplo n.º 9
0
from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.utils import is_request_type, is_intent_name
import ask_sdk_dynamodb
from ask_sdk_model.dialog import (ElicitSlotDirective, DelegateDirective)
from ask_sdk_model import (Response, IntentRequest, DialogState,
                           SlotConfirmationStatus, Slot)
from ask_sdk_model.ui import SimpleCard

import config

dbTable = os.environ["skill_persistence_table"]
skillId = os.environ["skill_id"]
skillName = config.config['skill_name']

sb = StandardSkillBuilder(table_name=dbTable,
                          auto_create_table=False,
                          partition_keygen=ask_sdk_dynamodb.partition_keygen.
                          user_id_partition_keygen)

###########################
# Launcher Request
###########################


@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
    attr = handler_input.attributes_manager.persistent_attributes
    session_attr = {
        'state': 'launch',
        'prev_state': '',
    }
Ejemplo n.º 10
0

class SessionEndedRequestHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return is_request_type("SessionEndedRequest")(handler_input)

    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())
Ejemplo n.º 11
0
import os
import time
import math
from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.utils import is_request_type, is_intent_name
import ask_sdk_dynamodb
from ask_sdk_core.dispatch_components import AbstractRequestHandler, AbstractExceptionHandler, \
    AbstractRequestInterceptor, AbstractResponseInterceptor

skill_persistence_table = os.environ["skill_persistence_table"]

SKILL_NAME = 'code counter'
sb = StandardSkillBuilder(table_name=skill_persistence_table,
                          auto_create_table=False,
                          partition_keygen=ask_sdk_dynamodb.partition_keygen.
                          user_id_partition_keygen)
'''
cat_facts = [
"A cat usually has about 12 whiskers on each side of its face.",
"On average, cats spend 2/3 of every day sleeping. That means a nine-year-old cat has been awake for only three years of its life.",
"In the original Italian version of Cinderella, the benevolent fairy godmother figure was a cat.",
"In the 1750s, Europeans introduced cats into the Americas to control pests.",
"Cats spend nearly 1/3 of their waking hours cleaning themselves.",
"A female cat is called a queen or a molly.",
"Rome has more homeless cats per square mile than any other city in the world.",
"Cats can drink seawater.",
"Cats are extremely sensitive to vibrations. Cats are said to detect earthquake tremors 10 or 15 minutes before humans can.",
"A cat's heart beats nearly twice as fast as a human heart, at 110 to 140 beats a minute."
]
'''
Ejemplo n.º 12
0
    def process(self, handler_input, response):
        # type: (HandlerInput, Response) -> None
        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()


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

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())
Ejemplo n.º 13
0
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(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())
Ejemplo n.º 14
0
import time

from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.utils import is_request_type, is_intent_name
import jmespath

from core import logger, log_invocation  # pylint: disable=no-name-in-module
import content
import models
import utils

# TODO: navigate home intent?
# TODO: support "make it harder/easier" and "change operation" intents
# TODO: prompt for a 5-star review

sb = StandardSkillBuilder(table_name=os.environ['SKILL_TABLE_NAME'])
sb.skill_id = 'amzn1.ask.skill.d455ad8c-dde9-4ee8-a492-4e3985b5ff79'
sb.custom_user_agent = 'alexa-math-practice-skill/1.0.0'

#
# helpers
#


def request_handler(request_type):
    def wrapper(fn):
        return sb.request_handler(is_request_type(request_type))(fn)

    return wrapper

Ejemplo n.º 15
0
skill_name = "Baby Data"
help_text = ("You can say baby slept at 2pm or "
             "had a diaper change at 2:30pm "
             "or that the last feed was at 11am")

sleep_slot_key = "SLEEP"
diaper_slot_key = "DIAPER"
feed_slot_key = "FEED"
baby_name_slot_key = "BABY"
sleep_slot = "Sleep"
diaper_slot = "Diaper"
feed_slot = "Feed"
baby_name_slot = "Baby"

# sb = SkillBuilder()
sb = StandardSkillBuilder(table_name="alexa-baby-data", auto_create_table=True)


@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
    # Handler for Skill Launch

    attr = handler_input.attributes_manager.persistent_attributes
    handler_input.attributes_manager.session_attributes = attr

    if not attr:
        missing_name_text = "What is the name of your baby? Say my baby's name is Jane"
        handler_input.response_builder.speak(missing_name_text).ask(
            missing_name_text)
        return handler_input.response_builder.response
Ejemplo n.º 16
0
from ask_sdk.standard import StandardSkillBuilder
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 import Response
from ask_sdk_model.ui import AskForPermissionsConsentCard
from ask_sdk_model.services import ServiceException

from auxilary import get_a_question, send_email

import requests

sb = StandardSkillBuilder(
    table_name='interview_me_users',
    auto_create_table=True,
)
skill_name = "Interview Me"
NOTIFY_MISSING_PERMISSIONS = """
Please enable email permissions in the Amazon Alexa app.
"""
ERROR = """
Something wen't bad. Please try again in a while.
"""
permissions = ["alexa::profile:email:read"]

CONTINUE_QUESTION = "What would you like to do next ? I can email this question to you, or you can tell me another topic to ask question from ?"


class LaunchRequestHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
Ejemplo n.º 17
0
        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
Ejemplo n.º 18
0
# Request and Response Loggers
class RequestLogger(AbstractRequestInterceptor):
    """Log the request envelope."""
    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())
        # type: (HandlerInput, Exception) -> bool
        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())
Ejemplo n.º 20
0
import os

from ask_sdk.standard import StandardSkillBuilder

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())
Ejemplo n.º 21
0
from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_model.ui import SimpleCard
from ask_sdk_model import Response
from the_whisperer_in_darkness import TheWhispererInDarkness
from the_whisperer_in_darkness import OctopusRoom
from slot_types import Room
from alexa_helper import StateHelper
from alexa_helper import AlexaHelper
from audio import Audio

SKILL_NAME = 'The Whisperer in Darkness'
sb = StandardSkillBuilder(table_name="The-Whisperer-In-Darkness",
                          auto_create_table=True)

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


@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
    """
    Handler for Skill Launch.
    """
    # type: (HandlerInput) -> Response
    state_variables = handler_input.attributes_manager.persistent_attributes
    if state_variables is None:
        state_variables = {}
    if not state_variables:
Ejemplo n.º 22
0
import logging
import gettext
from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.dispatch_components import (AbstractRequestHandler,
                                              AbstractExceptionHandler,
                                              AbstractRequestInterceptor,
                                              AbstractResponseInterceptor)
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

import data
import util

sb = StandardSkillBuilder(table_name=data.jingle["db_table"],
                          auto_create_table=True)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# ######################### INTENT HANDLERS #########################
# This section contains handlers for the built-in intents and generic
# request handlers like launch, session end, skill events etc.


class CheckAudioInterfaceHandler(AbstractRequestHandler):
    """Check if device supports audio play.

    This can be used as the first handler to be checked, before invoking
    other handlers, thus making the skill respond to unsupported devices
    without doing much processing.
    """
Ejemplo n.º 23
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()
Ejemplo n.º 24
0
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk.standard import StandardSkillBuilder
from ask_sdk_core.utils import is_intent_name, is_request_type
from ask_sdk_model import Response

import assistant
import skill_helpers
import data
from device_helpers import register_device, RegistrationError


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

_sb = StandardSkillBuilder(table_name=data.DYNAMODB_TABLE, auto_create_table=True)


def preflight_check(f: Callable) -> Callable:
    @wraps(f)
    def decorated_function(handler_input: HandlerInput) -> Response:
        _logger.info('Pre-flight check')

        # Obtain credentials
        credentials = skill_helpers.get_credentials(handler_input)

        # Obtain the deviceId
        device_id = skill_helpers.get_device_id(handler_input)
        last_device_id = skill_helpers.get_persistent_attribute(handler_input, 'device_id')

        project_id = data.GOOGLE_ASSISTANT_API['project_id']
Ejemplo n.º 25
0
from ask_sdk_model.ui import (AskForPermissionsConsentCard, SimpleCard,
                              StandardCard)
## Not sure why this import is different from line 34;
## commenting to see what happens:
#from ask_sdk_core.dispatch_components.exception_components import(
#    AbstractExceptionHandler
#)

# Local imports
import audio
import display
import events
import kilian_data
import session

sb = StandardSkillBuilder()
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.INFO)


# =============================================================================
# Main Handler
# =============================================================================
class LaunchRequestHandler(AbstractRequestHandler):
    """Object handling all initial requests. Launches the skill."""
    def can_handle(self, handler_input):
        """Inform the request handler of what intents can be handled."""
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        """Handle the launch request; fetch and serve appropriate response.
)

sample_saved_attributes = {
    '3': {
        'object': 'latte',
        'expiration': '2019-08-17',
        'token': 'bcccd595-58ca-4041-85c7-990ac9248c93'
    }
}

import boto3

dynamodb = boto3.resource('dynamodb', region_name='eu-west-1')

sb = StandardSkillBuilder(table_name="Scadenze",
                          auto_create_table=True,
                          partition_keygen=user_id_partition_keygen,
                          dynamodb_client=dynamodb)

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

welcome_speech = {
    "en-US": "Welcome. You can say: Add milk with expiration August 5th",
    "it-IT": "Ciao. Puoi dire: aggiungi latte con scadenza 5 Agosto."
}
FOOD_SLOT = "food"
DATE_SLOT = "date"
NOTIFY_MISSING_PERMISSIONS = (
    "Per favore, autorizza i Promemoria nella app Amazon Alexa.")

Ejemplo n.º 27
0
from planet_story.solar_questions import Question

# Const strings

STAR = 'star'
PLANET = 'planet'

BRIGHTNESS = 'brightness'
SIZE = 'size'
DISTANCE = 'distance'

SKILL_TITLE = 'Build A Planet'

# sb = SkillBuilder()

sb = StandardSkillBuilder()
planet_story: PlanetStory
device: Device


def get_slot_value_from_handler(handler_input, slot_name):
    return str(
        handler_input.request_envelope.request.intent.slots[slot_name].
        resolutions.resolutions_per_authority[0].values[0].value.name).lower()


def _load_apl_document(file_path):
    # type: (str) -> Dict[str, Any]
    """Load the apl json document at the path into a dict object."""
    with open(file_path) as f:
        return json.load(f)
Ejemplo n.º 28
0
# -*- coding: utf-8 -*-

# This is a High Low Guess game Alexa Skill.
# The skill serves as a simple sample on how to use the
# persistence attributes and persistence adapter features in the SDK.
import random
import logging

from ask_sdk.standard import StandardSkillBuilder
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

SKILL_NAME = 'High Low Game'
sb = StandardSkillBuilder(table_name="High-Low-Game", auto_create_table=True)

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


@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
    """Handler for Skill Launch.

    Get the persistence attributes, to figure out the game state.
    """
    # type: (HandlerInput) -> Response
    attr = handler_input.attributes_manager.persistent_attributes
    if not attr:
        attr['ended_session_count'] = 0
Ejemplo n.º 29
0
import json
import six

from ask_sdk.standard import StandardSkillBuilder
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, ui
from ask_sdk_model.slu.entityresolution import StatusCode

from lessons import LESSONS

SKILL_NAME = 'Auralias'
CARD_FOLDER = 'https://s3.amazonaws.com/auralias-alexa-skill/cards/'
MP3_FOLDER = 'https://s3.amazonaws.com/auralias-alexa-skill/mp3s/'

sb = StandardSkillBuilder(table_name="Auralias", auto_create_table=True)

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


def calculate_assessment_questions(subject, level):
    major_scale_formula = [0, 2, 2, 1, 2, 2, 2, 1]
    major_interval_names = ['unison', 'major 2nd', 'major 3rd', 'perfect 4th', 'perfect 5th', 'major 6th',
                            'major 7th', 'octave']
    major_interval_cards = [1, 2, 3, 4, 5, 6, 7, 8]
    start_note_midi_key_map = {
        'c_major_asc': 60,
        'd_major_asc': 62,
        'd_major_desc': 74
    }
Ejemplo n.º 30
0
        return None


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