Beispiel #1
0
def send(account_id, __, ___):
    """
    This function processes the content of the user confirmation message

    :param account_id: user account.
    """
    status, __, type, message = get_user_status(account_id)
    if status != "done" or message is None:
        # todo add error prompt
        raise HTTPError(500, "user status error. status error")

    content = make_text(
        "Your question has been sent to the person in charge. \n\n"
        "The staff will answer your question as soon as possible.")

    content1 = make_text("If you have any additional questions, "
                        "please select the task from below. "
                        "If you want to go back to the initial stage, "
                        "select [Go to Initial Menu] from the menu below.")

    content1["quickReply"] = create_quick_replay()

    title = "{type} inquiry details".format(type=type)
    prompt_message = yield create_articles(title, message, account_id)
    if prompt_message is not None:
        yield push_messages(account_id, [prompt_message])
        return

    clean_user_status(account_id)
    yield push_messages(account_id, [content, content1])
Beispiel #2
0
def start_content(account_id):
    yield register_rich_menun(account_id)

    content1 = make_text("Hello. I’m FAQ Bot. "
                         "I’m here to answer your office-related questions.")

    content2 = make_text("Please select an item from the menu below.")

    return [content1, content2]
Beispiel #3
0
def to_first(account_id, __, ___):
    process_flag = False
    if process_flag:
        content = make_text("Cannot be selected since you are currently "
                            "in Initial Menu. \n\n"
                            "Select it if you want to find FAQ or go back to "
                            "Initial Menu while the person in charge is "
                            "checking your question.")
    else:
        content = make_text("Moved to FAQ Initial Menu.")

    yield push_message(account_id, content)
Beispiel #4
0
def echo_display(message):
    """
    Generate messages that require user confirmation.

        reference
        - `Common Message Property <https://developers.worksmobile.com/jp/document/100500807?lang=en>`_

    Check also: faq_bot/model/data.py
    :param message: User input message.
    :return: Message to prompt users.
    """
    text = "Do you want to send the following as your question? \n\n" \
           "===\n{message}\n===".format(message=message)
    content = make_text(text)

    action0 = make_postback_action("send", label="Send", display_text="Send")
    item0 = make_quick_reply_item(action0)

    action1 = make_postback_action("modify",
                                   label="Modify",
                                   display_text="Modify")
    item1 = make_quick_reply_item(action1)

    action2 = make_postback_action("cancel",
                                   label="Cancel",
                                   display_text="Cancel")
    item2 = make_quick_reply_item(action2)

    quick_reply = make_quick_reply([item0, item1, item2])

    content["quickReply"] = quick_reply

    return content
Beispiel #5
0
def query(account_id, __, ___):
    # todo
    # 此处查询用户的咨询状态,如果用户在

    content1 = make_text("Please select an work-related item "
                         "that you would like to know.")

    content2 = image_introduce()

    yield push_messages(account_id, [content1, content2])
def enquire_message(account_id, callback, __):
    """
    This function prompts the user for a message.

    :param account_id: user account id.
    :param callback: Callback corresponding to business type.
    """
    content1 = make_text("You have selected {type}. "
                         "Please tell me your question.".format(
        type=TYPES[callback]))

    content2 = make_text("Only one message can be delivered. "
                         "Please write your question at one go.")

    yield asyncio.sleep(0.5)

    set_replace_user_info(account_id, 'wait_in', 'doing', TYPES[callback])

    yield push_messages(account_id, [content1, content2])
Beispiel #7
0
def enquire(account_id, __, ___):
    """
    This function handles the user's selection of ask a person

    :param account_id: user account id.
    """
    content = make_text("Select a task related to your question.")

    content["quickReply"] = create_quick_replay()

    yield push_message(account_id, content)
Beispiel #8
0
def transfer_message(account_id, callback, __):
    """
    This function prompts the user to go to ask someone.

    :param account_id: user account id.
    :param callback: Business type.
    """
    content1 = make_text(
        "Your question will be directly delivered to "
        "the person in charge of {type} "
        "to answer your question directly.".format(type=TYPES[callback]))

    content2 = make_text("Please tell me your question.\n"
                         "Only one message can be delivered. "
                         "Please write your question at one go.")

    yield asyncio.sleep(0.5)
    set_replace_user_info(account_id, 'wait_in', 'doing', TYPES[callback])

    yield push_messages(account_id, [content1, content2])
Beispiel #9
0
def query_leave(account_id, __, ___):
    """
    This function deals with the problems related to leave query.

    :param account_id: user account id.
    """
    text = make_text("Here are FAQs about HR and leave.")

    replay = create_quick_replay_item("transfer_leave",
                                      "Ask a charge")

    labels = ["more", "more", "more", "more"]

    """
    replay = create_quick_replay_item("transfer_leave",
                                      "Ask a person in charge")
    labels = ["See more", "See more", "See more", "See more"]
    titles = [
        "I would like to know the types of leave.",
        "I would like to know how many days of leave I have.",
        "I would like to request a leave.",
        "I would like to cancel my leave request."
    ]
    """
    titles = [
        "I would  of leave.",
        "I would leave I have.",
        "I would a leave.",
        "I would leave request."
    ]
    """
    texts = [
        "Leave including annual leave, paid leave, etc. "
        "is granted according to the Labor Standards Act.",
        "You can check the remaining days of your leave via "
        "the in-house browser.",
        "You can request a leave via the in-house browser.",
        "You can cancel your leave request via the in-house browser."
    ]
    """
    texts = [
        "Leave including to the Labor Standards Act.",
        "You can check the remain browser.",
        "You can request a leave via the in-house browser.",
        "You can cancel your leave in-house browser."
    ]

    carousel = create_carousel(labels, POST_BACK_URLS["leave"],
                    texts, CAROUSEL["leave"], titles)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
Beispiel #10
0
def query_welfare(account_id, __, ___):
    """
    This function deals with user query welfare related problems.

    :param account_id: user account id.
    """
    text = make_text("Here are FAQs about welfare and work support.")

    replay = create_quick_replay_item("transfer_welfare", "Ask a charge")
    labels = ["more", "more", "more", "more"]
    """
    labels = ["See more", "See more", "See more", "See more"]
    replay = create_quick_replay_item("transfer_welfare",
                                      "Ask a person in charge")
    titles = [
        "I would like to know the types of in-house welfare.",
        "What kinds of in-house clubs are there?",
        "Can I use a company car?",
        "How can I receive office supplies?"
    ]
    """

    titles = [
        "I would welfare.", "What clubs are there?", "Can I company car?",
        "How can office supplies?"
    ]
    """
    texts = [
        "In-house welfare includes the four main insurances, "
        "medical checkup, in-house clubs, etc.",
        "The company is supporting a variety of club activities "
        "such as sports, self-development, etc.",
        "Contact the Work Support Team to request a company car.",
        "Visit the Work Support Team to receive office supplies."
    ]
    """
    texts = [
        "In-house welfare in-house clubs, etc.",
        "The company is self-development, etc.",
        "Contact the to request a company car.",
        "Visit the  to receive office supplies."
    ]

    carousel = create_carousel(labels, POST_BACK_URLS["welfare"], texts,
                               CAROUSEL["welfare"], titles)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
Beispiel #11
0
def cancel(account_id, __, ___):
    """
    This function handles user cancellation inquiry.

    :param account_id: user account id.
    """
    status, _, __, ___ = get_user_status(account_id)
    if status != "done":
        # todo add error prompt
        raise HTTPError(500, "user status error. status error")

    content = make_text("You have canceled your question. "
                        "Please re-select the task from the menu below.")
    clean_user_status(account_id)
    yield push_message(account_id, content)
Beispiel #12
0
def storage_lack():
    return make_text("Failed to complete posting. \n\n"
                     "Ask the in-house manager if the public capacity is "
                     "not enough or if the capacity available for "
                     "domain use has been exceeded.")
Beispiel #13
0
def create_articles_failed():
    return make_text("Failed to complete posting. \n\n"
                     "Ask the FAQ Bot manager to check if the bulletin board "
                     "number does not exist or if other "
                     "items are set up incorrectly.")
Beispiel #14
0
def create_board_failed():
    return make_text("Failed to create bulletin board. \n\n"
                     "Ask the FAQ Bot manager to check if the bulletin board "
                     "creation item has been set incorrectly or "
                     "if the bulletin board title or description "
                     "has exceeded the character limit.")
Beispiel #15
0
def invalid_message():
    return make_text("I’m sorry. I couldn't understand the words. \n\n"
                     "Please select the function you want "
                     "from Bot Menu at the bottom of the chat window.")