Beispiel #1
0
def lambda_handler(request_obj, context=None):
    '''
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    metadata = {}
    return alexa.route_request(request_obj, metadata)
Beispiel #2
0
def lambda_handler(request, context=None):
    metadata = {}
    app_id = 'amzn1.echo-sdk-ams.app.a563fd76-b63a-43bd-9d92-9af0bbe27e14'
    if not request.session['application']['applicationId'] == app_id:
        return alexa.create_response('yeah nice try.')

    return alexa.route_request(request, metadata)
def lambda_handler(request_obj, context=None):
    '''
    This is the main function to enter to enter into this code.
    If you are hosting this code on AWS Lambda, this should be the entry point.
    Otherwise your server can hit this code as long as you remember that the
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    # Setup configuration vars from lambda environment (lazy code)
    api_base = os.environ['api_base']
    user_name = os.environ['user']
    password = os.environ['password']
    skill_id = os.environ['skill_id']
    event_session = None   # event['session']

    # Get session ID
    session_token = create_ns_session(api_base, user_name, password, event_session)
    logging.debug("create_ns_session: token = %s", session_token)
    logging.debug("create_ns_session: api_base = %s", api_base)

    metadata = {'user_name': user_name,
                'password': password,
                'api_base': api_base,
                'token': session_token,
                'skill_id': skill_id}

    ''' inject user relevant metadata into the request if you want to, here.    
    e.g. Something like : 
    ... metadata = {'user_name' : some_database.query_user_name(request.get_user_id())}

    Then in the handler function you can do something like -
    ... return alexa.create_response('Hello there {}!'.format(request.metadata['user_name']))
    '''
    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    '''
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    metadata = {}
    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    print "S3 Config is bucket {} with key {}".format(S3_BUCKET, S3_KEY)

    if request_obj['session']['application']['applicationId'] != APPLICATION_ID:
        raise ValueError("Invalid Application ID")

    return alexa.route_request(request_obj)
Beispiel #6
0
def lambda_handler(request_obj, context=None):

    myUsageMonths = {}

    jsonStr = getUsage()

    if jsonStr == None:
        card = alexa.create_card(title="GetInternetUsage activated",
                                 subtitle=None,
                                 content="asked alexa to get internet usage")
        return alexa.create_response(
            "Sorry unable to retrieve comcast account information",
            end_session=True,
            card_obj=card)

    jsonObj = json.loads(jsonStr)

    usageMonths = jsonObj['usageMonths']

    for usageMonth in usageMonths:
        monthName = calendar.month_name[int(usageMonth['startDate'][:2])]
        myUsageMonths[monthName] = MyUsage(monthName,
                                           usageMonth['unitOfMeasure'],
                                           usageMonth['homeUsage'],
                                           usageMonth['allowableUsage'])

    metadata = {'usageMonths': myUsageMonths}

    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    '''
    This is the main function to enter to enter into this code.
    If you are hosting this code on AWS Lambda, this should be the entry point.
    Otherwise your server can hit this code as long as you remember that the
    input 'request_obj' is JSON request converted into a nested python object.
    '''
    # add your own metadata to the request using key value pairs
    metadata = {'user_name': 'SomeUserName'}
    ''' inject user relevant metadata into the request if you want to, here.
    e.g. Something like :
    ... metadata = {'user_name' : some_database.query_user_name(request.get_user_id())}
    Then in the handler function you can do something like -
    ... return alexa.create_response('Hello there {}!'.format(request.metadata['user_name']))
    '''
    '''
    Tring to load pizza menus in to global variables
    '''
    global HasLoaded
    if not HasLoaded:
        menuHandler = MenuHandler()
        # pizza types
        global PIZZAS
        for pizza in menuHandler.getPizzaTypes():
            PIZZAS.append(pizza[0].lower())
        # pizza sizes
        global SIZES
        for size in menuHandler.getPizzaSizes():
            SIZES.append(size[0].lower())
        # pizza crusts
        global CRUSTS
        for crust in menuHandler.getPizzaCrusts():
            CRUSTS.append(crust[0].lower())
        # pizza bakes
        global BAKES
        for bake in menuHandler.getPizzaBakes():
            BAKES.append(bake[0].lower())
        # pizza sauces
        global SAUCES
        for s in menuHandler.getPizzaSauces():
            SAUCES.append(s[0].lower())
        # pizza cuts
        global CUTS
        for c in menuHandler.getPizzaCuts():
            CUTS.append(c[0].lower())
        # pizza toppings
        global TOPPINGS
        for topping in menuHandler.getPizzaToppings():
            TOPPINGS.append(topping[0].lower())
        # pizza seasonings
        global SEASONINGS
        for topping in menuHandler.getPizzaSeasonings():
            SEASONINGS.append(topping[0].lower())

        # set flag to true
        HasLoaded = True

    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    '''
    This is the main function to enter to enter into this code.
    If you are hosting this code on AWS Lambda, this should be the entry point.
    Otherwise your server can hit this code as long as you remember that the
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    metadata = dict()
    return alexa.route_request(request_obj, metadata)
Beispiel #9
0
def lambda_handler(request_obj, context=None):
    '''
    This is the main function to enter to enter into this code.
    If you are hosting this code on AWS Lambda, this should be the entry point.
    Otherwise your server can hit this code as long as you remember that the
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    metadata = {'user_name' : 'SomeRandomDude'} # add your own metadata to the request using key value pairs

    ''' inject user relevant metadata into the request if you want to, here.
    e.g. Something like :
    ... metadata = {'user_name' : some_database.query_user_name(request.get_user_id())}

    Then in the handler function you can do something like -
    ... return alexa.create_response('Hello there {}!'.format(request.metadata['user_name']))
    '''
    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    '''
    This is the main function to enter to enter into this code.
    If you are hosting this code on AWS Lambda, this should be the entry point.
    Otherwise your server can hit this code as long as you remember that the
    input 'request_obj' is JSON request converted into a nested python object.
    '''

    metadata = {'user_name' : 'SomeRandomDude'} # add your own metadata to the request using key value pairs
    
    ''' inject user relevant metadata into the request if you want to, here.    
    e.g. Something like : 
    ... metadata = {'user_name' : some_database.query_user_name(request.get_user_id())}

    Then in the handler function you can do something like -
    ... return alexa.create_response('Hello there {}!'.format(request.metadata['user_name']))
    '''
    return alexa.route_request(request, metadata)
def lambda_handler(request_obj, context={}):
    ''' All requests start here '''    
    return alexa.route_request(request_obj)
Beispiel #12
0
def lambda_handler(request_obj, context={}):
    return alexa.route_request(request_obj)
Beispiel #13
0
def lambda_handler(request_obj, context={}):
    return alexa.route_request(request_obj)
def handler(request_obj, context={}):
    ''' All requests start here '''
    return alexa.route_request(request_obj)
Beispiel #15
0
def lambda_handler(request_obj, context=None):
    print(request_obj)
    metadata = {}
    return alexa.route_request(request_obj, metadata)
def lambda_handler(request_obj, context=None):
    metadata = {} 
    return alexa.route_request(request_obj, metadata)
Beispiel #17
0
def lambda_handler(request_obj, context={}):
    ''' All requests start here '''
    print "request object is " , request_obj
    return alexa.route_request(request_obj)