Ejemplo n.º 1
0
def call_back_intent_handler(request):
    """
    You can insert arbitrary business logic code here
    """
    rap = get_rhyme(chains["toponehundredraps"], 8)
    upload_rap(rap[7:-94])
    return r.create_response(is_ssml=True, message="<speak>Aight yo I'm gonna rap. Alexa <break time=\"1.5s\" /> start beatboxing <break time=\"1.5s\" />  "  + rap + '<audio src="https://s3.amazonaws.com/danielgwilson.com/MLG+Horns+Sound+Effect.mp3" /></speak>')
Ejemplo n.º 2
0
def launch_request_handler(request):
    """
    Annoatate functions with @VoiceHandler so that they can be automatically mapped 
    to request types.
    Use the 'request_type' field to map them to non-intent requests
    """
    return r.create_response(message="Hello Welcome to My Recipes!")
Ejemplo n.º 3
0
def get_welcome_intent_handler(request):
    response_text = "Welcome to the Los Angeles A.W.S Meetup. \
    This month we're talking about A.W.S Lambda, and what better way to demo Lambda than to \
    have Alexa call Lambda Functions. This demo function will call the Meetup A.P.I and check \
    to see who R S V P'd for this event and randomly pick one of those members to win an Amazon Echo."
    return r.create_response(message=response_text,
                             end_session=True)
Ejemplo n.º 4
0
def get_winner_intent_handler(request):
    winner =PickAWinner()
    print("[debug] Called the PickWinnerIntent Intent")
    card = r.create_card(title="Picking Winners!",
                         subtitle=None,
                         content="The winner is " + winner)

    return r.create_response(message="The winner is " + winner,
                             end_session=True,
                             card_obj=card)
Ejemplo n.º 5
0
def get_rapper_intent_handler(request):
    """
    Use the 'intent' field in the VoiceHandler to map to the respective intent.
    You can insert arbitrary business logic code here
    """

    # Get variables like userId, slots, intent name etc from the 'Request' object
    rapper = request.get_slot_value("Rapper")
    rapper = rapper if rapper else ""

    with open("models/intros.json") as file:
        intros = json.load(file)

    try:
        intro = intros[rapper]
    except KeyError:
        intro = ""

    try:
        rap = get_rhyme(chains[rapper], 8)
    except KeyError:
        return r.create_response(message="I heard, %s, but I don't know that rapper." % rapper, end_session=False)

    rap = "<speak>Yo my name is {}. ".format(rapper) + intro + " " + rap + '<audio src="https://s3.amazonaws.com/danielgwilson.com/MLG+Horns+Sound+Effect.mp3" /></speak>'

    upload_rap(rap[7:-94])

    # Use ResponseBuilder object to build responses and UI cards
    card = r.create_card(title="Rapping",
                         subtitle=None,
                         content=rap)


    return r.create_response(message=rap,
                             is_ssml=True,
                             end_session=False,
                             card_obj=card)
Ejemplo n.º 6
0
def get_recipe_intent_handler(request):
    """
    Use the 'intent' field in the VoiceHandler to map to the respective intent.
    You can insert arbitrary business logic code here    
    """

    # Get variables like userId, slots, intent name etc from the 'Request' object
    ingredient = request.get_slot_value("Ingredient") 
    ingredient = ingredient if ingredient else ""

    #Use ResponseBuilder object to build responses and UI cards
    card = r.create_card(title="GetRecipeIntent activated",
                         subtitle=None,
                         content="asked alexa to find a recipe using {}"
                         .format(ingredient))
    
    return r.create_response(message="Finding a recipe with the ingredient {}".format(ingredient),
                             end_session=False,
                             card_obj=card)
Ejemplo n.º 7
0
def get_help_intent_handler(request):
    """
    Use the 'intent' field in the VoiceHandler to map to the respective intent.
    You can insert arbitrary business logic code here
    """

    # Get variables like userId, slots, intent name etc from the 'Request' object
    # ingredient = request.get_slot_value("Ingredient")
    # ingredient = ingredient if ingredient else ""

    #Use ResponseBuilder object to build responses and UI cards
    print("[debug] Called the HelpIntent Intent")
    card = r.create_card(title="Handy Helper",
                         subtitle=None,
                         content="Ok, you need some help")

    return r.create_response(message="Ok, you need some help",
                             end_session=True,
                             card_obj=card)
Ejemplo n.º 8
0
def call_back_intent_handler(request):
    """
    You can insert arbitrary business logic code here
    """
    return r.create_response(message="Getting Next Recipe ... 123")
Ejemplo n.º 9
0
def session_ended_request_handler(request):
    return r.create_response(message="Goodbye!")
Ejemplo n.º 10
0
def default_handler(request):
    """ The default handler gets invoked if no handler is set for a request """
    return r.create_response(message="Just ask")
Ejemplo n.º 11
0
def build_response(message=None, end_session=False, card_obj=None, sessionAttributes={'session' : 'null'}, reprompt_message=help_message):
    ''' Method to build and return the response back to the user '''
    response = r.create_response(message=message, end_session=end_session, card_obj=card_obj, reprompt_message=reprompt_message)
    response['sessionAttributes'] = sessionAttributes
    return response
Ejemplo n.º 12
0
def call_back_intent_handler(request):
    """
    You can insert arbitrary business logic code here
    """
    return r.create_response(message="boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and boots and cats and ")
Ejemplo n.º 13
0
def session_ended_request_handler(request):
    print("[debug] Request type was SessionEndedRequest")
    return r.create_response(message="Goodbye!")
Ejemplo n.º 14
0
def default_handler(request):
    """ The default handler gets invoked if no handler is set for a request """
    print("[debug] Didn't match any intents, therefore we invoked the default handler")
    return r.create_response(message="Just ask")