Exemple #1
0
def get_time_intent_handler(request):
    db = Database(request.user_id()) 
    cookTime = db.getRecipeInfo("CookTime")

    outMessage = ""

    try:
        if (cookTime < 0):
            outMessage = "Time information was not provided for this recipe"
        else:
            cookTime.replace('PT', '')
            outMessage = "The cook time for this recipe is: " + cookTime
            return r.create_response(message=outMessage)

        totalTime = db.getRecipeInfo("TotalTime")

        if (totalTime < 0):
            outMessage = "Time information was not provided for this recipe"
        else:
            totalTime.replace('PT', '')
            outMessage = "The total time taken for this recipe is: " + totalTime
            return r.create_response(message=outMessage)

    except:
        outMessage = "Time information was not provided for this recipe"

    return r.create_response(message=outMessage, reprompt_message=rePrompt)
Exemple #2
0
def next_recipe_intent_handler(request):
    """
        gets the top three URLS for the desired type of recipes
    """
    food = request.get_slot_value("FindRecipe")

    outMessage = ""
 
    # go find a recipe
    try:
        webPage = scrape.FindRecipe(food)
    except:
        outMessage = "Please start over and phrase the request in another way. "+\
                     "I had trouble hearing what you said."
        return r.create_response(message=outMessage)

    webPage.storeTopFive()
    topRecipes = webPage.returnTopFive()
    
    db = Database(request.user_id())
    db.updateLinks(topRecipes)
    topRecipes.sort()

    outMessage = "The top 3 {0} recipes are 1. {1}, 2. {2}, and 3. {3}.".format(food,
                                                                       topRecipes[0][0],
                                                                       topRecipes[1][0],
                                                                       topRecipes[2][0])
    outMessage += " Which one would you like to make?"
    rePrompt = "Please pick an option 1 through 3."

    return r.create_response(message=outMessage, reprompt_message=rePrompt)
def set_fox_intent_handler(request):
    response = requests.get('https://www.sheet3.com:5007/fox', auth=(username, password))

    if response.status_code == 202:
        return r.create_response(message=replies[rand_int()], end_session=True)
    else:
        return r.create_response(message="I cannot talk to the house", end_session=True)
    return
def set_fox_intent_handler(request):
    response = requests.get('https://www.sheet3.com:5007/fox',
                            auth=(username, password))

    if response.status_code == 202:
        return r.create_response(message=replies[rand_int()], end_session=True)
    else:
        return r.create_response(message="I cannot talk to the house",
                                 end_session=True)
    return
Exemple #5
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!")
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="Jarvis is waiting for further input", end_session=True)
Exemple #7
0
def repeat_intent_handler(request):
    """
        Should repeat the last command entered
    """
    db = Database(request.user_id()) 
    ingStepNum = int(db.getItem("IngStep"))
    dirStepNum = int(db.getItem("DirStep"))
    totalIng = int(db.getRecipeItem("TotalIng"))
    totalStep = int(db.getRecipeItem("TotalStep"))

    outMessage = ""
    if (ingStepNum < 0 and dirStepNum < 0):
        outMessage = "I can help you find a recipe for a meal, or " +\
                     "load a custom recipe of yours! What would you like me to do?"

    if (ingStepNum >= 0 and ingStepNum < totalIng):
        if (ingStepNum != 0):
            db.setItem("IngStep", ingStepNum - 1)
            outMessage = db.getNextIngredient()
            db.setItem("IngStep", ingStepNum)

    elif (dirStepNum >= 0 and dirStepNum <= totalStep):
        if (dirStepNum != 0):
            db.setItem("DirStep", dirStepNum - 1)
            outMessage = db.getNextStep()
            db.setItem("DirStep", dirStepNum)
    
    return r.create_response(message=outMessage, reprompt_message="Say next to continue")
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!")
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="Jarvis is waiting for further input",
                             end_session=True)
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)
Exemple #11
0
def next_recipe_intent(request):
    """
        Plays the first ingredient
    """

    db = Database(request.user_id())
    ingStepNum = int(db.getItem("IngStep"))
    dirStepNum = int(db.getItem("DirStep"))
    totalIng = int(db.getRecipeItem("TotalIng"))
    totalStep = int(db.getRecipeItem("TotalStep"))
    outMessage = ""

    if (ingStepNum < 0 and dirStepNum < 0):
        # if both our steps are -1 then we start with
        # ingredients first
        db.setItem("IngStep", 0)
        ingStepNum = 0
        outMessage = "You'll need: "

    if (ingStepNum >= 0 and ingStepNum < totalIng):
        # set our outMessage to be the ingredient
        # and then update our ingredient counter
        outMessage += db.getNextIngredient()
        db.setItem("IngStep", ingStepNum + 1)
        db.setItem("DirStep", -1)

        if (ingStepNum + 1 == totalIng):
            outMessage = "Now, here are the directions: "
            db.setItem("DirStep", 0)
            db.setItem("IngStep", -1)

    elif (dirStepNum >= 0 and dirStepNum < totalStep):
        outMessage += db.getNextStep()
        db.setItem("IngStep", -1)
        db.setItem("DirStep", dirStepNum + 1)

    if (dirStepNum == totalStep and ingStepNum < 0):
        outMessage = "That's the whole recipe! Enjoy your meal! Cookmate: out."
        return r.create_response(message=outMessage, end_session=True)

    return r.create_response(message=outMessage,
                             reprompt_message="Say next to continue",
                             end_session=True)
Exemple #12
0
def launch_request_handler(request):
    """
    Annotate 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
    """
    outMessage = "Hello! I'm Cookmate, your best friend in the kitchen! " +\
                 "I can help you find a recipe for a meal, or " +\
                 "load a custom recipe of yours! What would you like me to do?"
    return r.create_response(message=outMessage)
Exemple #13
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)
Exemple #14
0
def get_nut_intent_handler(request):
    """
        returns how many calories in a recipe
    """
    db = Database(request.user_id())
    nutritionInfo = int(db.getRecipeInfo("NutritionInfo"))

    outMessage = "I'm sorry, nutrition information is not available on this recipe."
    if (nutritionInfo >= 0):
        outMessage = "There are " + str(nutritionInfo) + " calories per serving in this recipe."

    return r.create_response(message=outMessage)
Exemple #15
0
def get_recipe_intent_handler(request):
    """
        Loads and prepares a custom recipe from the user input
    """
    # Get variables like userId, slots, intent name etc from the 'Request' object
    recipe = request.get_slot_value("LoadRecipe") 
    recipe = recipe if recipe else ""
    outMessage = "Your " + recipe + " recipe is ready to be made. Say start or next to continue."
    recipe = scrape.Recipe(custom = recipe)
    db = Database(request.user_id())
    db.loadRecipe(recipe)
    return r.create_response(message=outMessage)
Exemple #16
0
def get_info_intent(request):
    """
        Returns the specific piece of information the user asked for
    """
    userIng = request.get_slot_value("Ingredient")
    db = Database(request.user_id())
    ingredients = db.getAllIngredients()

    outMessage = "I'm sorry, I didn't find {0} in the ingredients.".format(userIng)

    if userIng:
        for ingredient in ingredients:
            if (userIng in ingredient):
                outMessage = "You need " + str(ingredient) + " for this recipe."

    ovenBool = request.get_slot_value("Appliance")
    ovenBool = ovenBool if ovenBool == "oven" else ""
    if ovenBool:
        outMessage = "The oven needs to be set to " 
        outMessage += str(db.getRecipeItem("OvenTemp"))

    return r.create_response(message=outMessage)
Exemple #17
0
def choose_recipe_intent_handler(request):
    """
        Gets the information for the next recipe that they will be making
    """
    # check for no recipe specified yet
    
    choiceNum = request.get_slot_value("Choice")
    
    if ((1 <= int(choiceNum)) and (int(choiceNum) <= 3)):
        db = Database(request.user_id())
        db.updateChoice(choiceNum)
        # get what step we're on
        db.setItem("IngStep", -1)
        db.setItem("DirStep", -1)
        
        link = db.getLink(choiceNum)
        print(link)
        recipe = scrape.Recipe(link)
        db.loadRecipe(recipe)

    outMessage = recipe.nameOfRecipe + " selected. "
    outMessage += "Say: 'start' to continue, or, 'cancel' to end."

    return r.create_response(message=outMessage)
Exemple #18
0
def session_ended_request_handler(request):
    db = Database(request.user_id())
    db.setItem("IngStep", -1)
    db.setItem("DirStep", -1)
    return r.create_response(message="Enjoy your meal!")
Exemple #19
0
def next_recipe_intent_handler(request):
    """
    You can insert arbitrary business logic code here
    """
    return r.create_response(message="Getting Next Recipe ... 123")
Exemple #20
0
def default_handler(request):
    """ The default handler gets invoked if no handler is set for a request """
    outMessage = "I can find you a recipe, list your recipes, or load a custom recipe."
    return r.create_response(message=outMessage)
Exemple #21
0
def finish_intent_handler(request):
    db = Database(request.user_id())
#    db.setItem("IngStep", -1)
#    db.setItem("DirStep", -1)
    return r.create_response(message="Enjoy your meal!", end_session=True)
def default_handler(request):
    """ The default handler gets invoked if no handler is set for a request """
    return r.create_response(message="Just ask")
def session_ended_request_handler(request):
    return r.create_response(message="Goodbye!")
Exemple #24
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")
def next_recipe_intent_handler(request):
    """
    You can insert arbitrary business logic code here
    """
    return r.create_response(message="Getting Next Recipe ... 123")
Exemple #26
0
def session_ended_request_handler(request):
    return r.create_response(message="Goodbye!")