예제 #1
0
def action_func():
    metrics = manager.get('data').get('metrics')
    if len(metrics) > 1:
        return event('SelectMetricToSort')

    else:
        return event('AskSortType')
        speech = """How would you like to sort {}?

                a) from largest to smallest
                b) from smallest to largest""".format(metrics[0])
        return ask(speech)
예제 #2
0
def action_func():

    # Checking if option is selected
    if (context_manager.get("actions_intent_option")) is not None:
        option = context_manager.get("actions_intent_option").get(
            "OPTION")  # getting the key sent
        if option == "flask_assistant":
            return event("assistCarousel")  # returning events
        elif option == "flask_ask":
            return event("fAsk")  # returning events
        elif option == "flask":
            return event("fCard")  # returning events

    # Basic speech/text response
    resp = ask("Select Flask-Assistant for a carousel")

    # Create a list with a title
    mylist = resp.build_list("Awesome List")

    # Add items directly to list
    mylist.add_item(
        "Flask-Assistant",
        key="flask_assistant",  # query sent if item selected
        img_url=ASSIST_LOGO_URL,
        description="Select for carousel",
        synonyms=["flask assistant", "number one", "assistant", "carousel"],
    )

    mylist.add_item(
        "Flask-Ask",
        key="flask_ask",
        img_url=ASK_LOGO_URL,
        description=
        "Rapid Alexa Skills Kit Development for Amazon Echo Devices",
        synonyms=["ask", "flask ask", "number two"],
    )

    # Or build items independent of list
    flask_item = build_item(
        "Flask",
        key="flask",
        img_url=FLASK_LOGO_URL,
        description=
        "A microframework for Python based on Werkzeug, Jinja 2 and good intentions",
        synonyms=["flask", "number three"],
    )

    # and add them to the lsit later
    mylist.include_items(flask_item)

    return mylist
예제 #3
0
def action_func(scope=None, choices=None):
    if choices and not scope:
        scope_data = scope_choices[choices]
    else:
        scope_data = scope
    manager.get('data').set('store-scope', scope_data)
    manager.add(scope_data + '-stores')

    if scope_data == 'all':  # stores are selected - all of them
        manager.get('data').set('stores', 'all')
        manager.add('stores-selected')
        return event('SelectMeasureType')

    else:  # need to choose the stores, then select mesauretype
        return event('SelectStores')
예제 #4
0
def action_func():

    #Checking if option is selected
    if (context_manager.get('actions_intent_option')) is not None:
        option = context_manager.get('actions_intent_option').get(
            'OPTION')  #getting the key sent
        if (option == "flask_assistant"):
            return event('assistCarousel')  #returning events
        elif option == 'flask_ask':
            return event('fAsk')  #returning events
        elif option == 'flask':
            return event('fCard')  #returning events

    # Basic speech/text response
    resp = ask("Select Flask-Assistant for a carousel")

    # Create a list with a title
    mylist = resp.build_list('Awesome List')

    # Add items directly to list
    mylist.add_item(
        'Flask-Assistant',
        key='flask_assistant',  # query sent if item selected
        img_url=ASSIST_LOGO_URL,
        description='Select for carousel',
        synonyms=['flask assistant', 'number one', 'assistant', 'carousel'])

    mylist.add_item(
        'Flask-Ask',
        key='flask_ask',
        img_url=ASK_LOGO_URL,
        description=
        'Rapid Alexa Skills Kit Development for Amazon Echo Devices',
        synonyms=['ask', 'flask ask', 'number two'])

    # Or build items independent of list
    flask_item = build_item(
        'Flask',
        key='flask',
        img_url=FLASK_LOGO_URL,
        description=
        'A microframework for Python based on Werkzeug, Jinja 2 and good intentions',
        synonyms=['flask', 'number three'])

    # and add them to the lsit later
    mylist.include_items(flask_item)

    return mylist
예제 #5
0
def action_func(measure_type=None, choices=None):
    if choices and not measure_type:
        measure_type_data = measure_choices[choices]
    else:
        measure_type_data = measure_type
    manager.get('data').set('store-measure', measure_type_data)
    return event('AskSortType')
예제 #6
0
def action_func(scope=None,
                choices=None):  # choice/scope not list because need one answer
    if choices and not scope:
        scope_data = scope_choices[choices]
    else:
        scope_data = scope

    manager.get('data').set('product-scope', scope_data)
    manager.add(scope_data + '-products')

    if scope_data == 'all':  # Products are selected - all of them
        manager.get('data').set('products', 'all')
        manager.add('products-selected')
        return event('SelectMeasureType')

    else:  # need to choose the products, then select mesauretype
        return event('SelectProducts')
예제 #7
0
파일: index.py 프로젝트: Shubh18s/djs_woz
def attempt1():
    db_user = SessionLocal()
    time.sleep(3.4)
    wiz_db_resp = db_user.query(models.UserQuery).order_by(models.UserQuery.id.desc()).first().wizard_response
    db_user.close()
    if(wiz_db_resp== "No Response"):
        return event('attempt-2')
    else:
        return ask(str(wiz_db_resp))
예제 #8
0
def begin_time_dialogue(date_time):

    # interval
    if '/' in date_time:

        delta = parse_date_interval(date_time)
        manager.get('data').set('time-delta', str(delta))
        ask_period = largest_period(delta.days)

        manager.add(ask_period, lifespan=1)
        return event('StepToProducts')

    else:
        return ask(
            "Sorry I cant do single dates yet. Is there a range of time you'd like to see?"
        )
예제 #9
0
def incorrect_guess(game, correct_answer):

    speech_options_incorrect = [
        "Oh no! That is not correct! The correct answer was: {}.".format(
            correct_answer),
        "Sorry! That wasn't correct! The correct answer was: {}.".format(
            correct_answer)
    ]

    game.incorrect_guess()
    save_game(game)
    if game.strikes == 0:
        return event("game_over")
    else:
        speech = choice(speech_options_incorrect)
        speech = speech + " " + get_round_over_text(game.hints, game.strikes)
        context_manager.add("user_round_response", lifespan=5)
        return ask(speech)
예제 #10
0
def correct_guess(game):

    speech_options = [
        "That's correct! What comes next?",
        "Right answer! What is your next guess?",
        "Nice job! Now what comes next?"
    ]

    max_count = len(game.game_sequence)
    if game.round_count == max_count and game.guess_count == max_count and not game.strike_in_progress:
        save_game(game)
        return event("won_game")
    elif game.guess_count == max_count and not game.strike_in_progress:
        speech = "Correct! " + get_round_over_text(game.hints, game.strikes)
        context_manager.add("user_round_response", lifespan=5)
        save_game(game)
        return ask(speech)
    else:
        game.correct_guess()
        save_game(game)
        context_manager.add("guess", lifespan=1)
        return ask(choice(speech_options))
예제 #11
0
파일: index.py 프로젝트: Shubh18s/djs_woz
def webhook():

    db_user = SessionLocal()

    data = request.get_json(silent=True)
    query = data['queryResult']['queryText']
    global user_utter

    # Set global variable that wizard listens to for query
    user_utter = query

    # Add new query to db
    new_user_utr = models.UserQuery(user_request=query)
    db_user.add(new_user_utr)
    db_user.commit()

    time.sleep(3.4)

    wiz_db_resp = db_user.query(models.UserQuery).order_by(models.UserQuery.id.desc()).first().wizard_response
    db_user.close()
    if(wiz_db_resp== "No Response"):
        return event('attempt-1')
    else:
        return ask(str(wiz_db_resp))
예제 #12
0
def first_round_confirmation():
    return event("start_round")
예제 #13
0
def select_strategy(existing_strategy):
    return event("strat-config-start", existing_strategy=existing_strategy)
예제 #14
0
def begin_mode_prompt():
    return event("strat-mode-start")
예제 #15
0
def action_func(metrics):
    manager.get('data').set('sort-metric', metrics)
    return event('AskSortType')
예제 #16
0
def store_answer(answer):
    manager.add('ask-byday', lifespan=1)
    manager.get('data').set('byweek', answer)
    return event('StepToProducts')
예제 #17
0
def store_answer(answer):
    manager.add('time-periods-complete')  # always end with day
    manager.get('data').set('byday', answer)
    return event('AskProductScope')
예제 #18
0
def action_func(products):
    manager.get('data').set('products', products)
    manager.add('products-selected')
    return event('SelectMeasureType')
예제 #19
0
def round_response(round_response, game):
    save_game(load_game())
    if 'n' in round_response:
        return event("end_game")
    else:
        return event("start_round")
예제 #20
0
def action_func(stores):
    manager.get('data').set('stores', stores)
    manager.add('stores-selected')
    return event('SelectMeasureType')