Ejemplo n.º 1
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.
    """
    fmt = _("Your question will be directly delivered to the person "
            "in charge of {type} to answer your question directly.")
    content1 = make_i18n_text(
        "Your question will be directly delivered to "
        "the person in charge of {type} "
        "to answer your question directly.".format(type=TYPES[callback]),
        "transfer_message",
        fmt,
        type=callback)

    fmt1 = _(
        "Please tell me your question.\n\nOnly one message can be delivered. "
        "Please write your question at one go.")
    content2 = make_i18n_text(
        "Please tell me your question.\n\n"
        "Only one message can be delivered. "
        "Please write your question at one go.", "transfer_message", fmt1)

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

    yield push_messages(account_id, [content1, content2])
Ejemplo n.º 2
0
def to_first(account_id, __, ___):
    process_flag = True
    status, __, type, message = get_user_status(account_id)
    if status is not None:
        clean_user_status(account_id)
        process_flag = False

    if process_flag:
        fmt = _(
            "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.")
        content = make_i18n_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.", "to_first", fmt)
    else:
        fmt = _(
            "Moved to FAQ Initial Menu.\n\nPlease select an item from the menu below."
        )
        content = make_i18n_text(
            "Moved to FAQ Initial Menu.\n\nPlease select an item from the menu below.",
            "to_first", fmt)

    yield push_message(account_id, content)
Ejemplo n.º 3
0
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.
    """

    fmt = _("You have selected {type}. Please tell me your question.")
    content1 = make_i18n_text(
        "You have selected {type}. "
        "Please tell me your question.".format(type=TYPES[callback]),
        "enquire_message",
        fmt,
        type=callback)

    fmt = _("Only one message can be delivered. "
            "Please write your question at one go.")
    content2 = make_i18n_text(
        "Only one message can be delivered. "
        "Please write your question at one go.", "enquire_message", fmt)

    yield asyncio.sleep(0.5)

    set_replace_user_info(account_id, 'wait_in', 'doing', callback)

    yield push_messages(account_id, [content1, content2])
Ejemplo n.º 4
0
def start_content(account_id):
    yield register_rich_menun(account_id)

    fmt = _("Hello. I’m FAQ Bot. "
            "I’m here to answer your office-related questions.")
    content1 = make_i18n_text("Hello. I’m FAQ Bot. I’m here to answer your "
                              "office-related questions.", "start", fmt)

    fmt1 = _("Please select an item from the menu below.")
    content2 = make_i18n_text("Please select an item from the menu below.",
                              "start", fmt1)

    return [content1, content2]
def query_security(account_id, __, ___):
    """
    This function deals with user query security related problems.

    :param account_id: user account id.
    """
    status, __, type, message = get_user_status(account_id)
    if status == "wait_in":
        set_user_status(account_id, status="none")

    fmt = _("Here are FAQs about security.")
    text = make_i18n_text("Here are FAQs about security.", "query_security", fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_security", "query_security",
                                      "Send a question", fmt)

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

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "I lost my access card.",
        "My access card has been damaged.",
        "Can visitors enter the office?",
        "I can’t remember my computer password."
    ]
    
    i18n_title_fmts = [
        _("I lost my access card."),
        _("My access card has been damaged."),
        _("Can visitors enter the office?"),
        _("I con’t remember my computer password.")
    ]
    texts = [
        "Contact the Security Team to reissue your access card.",
        "Contact the Security Team to reissue your access card.",
        "Contact the Security Team in advance to gain access.",
        "Contact the Security Team to change your computer password."
    ]

    fmt = _("Contact the Security Team to reissue your access card.")
    i18n_text_fmts = [
        fmt,
        fmt,
        _("Contact the Security Team in advance to gain access."),
        _("Contact the Security Team to change your computer password.")
    ]

    carousel = create_carousel("query_security", labels,
                               POST_BACK_URLS["security"], texts, titles,
                               CAROUSEL["security"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
Ejemplo n.º 6
0
def to_first(account_id, __, ___):
    process_flag = False
    if process_flag:
        fmt = _("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.")
        content = make_i18n_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.", "to_first", fmt)
    else:
        fmt = _("Moved to FAQ Initial Menu.")
        content = make_i18n_text("Moved to FAQ Initial Menu.", "to_first", fmt)

    yield push_message(account_id, content)
Ejemplo n.º 7
0
def query_welfare(account_id, __, ___):
    """
    This function deals with user query welfare related problems.

    :param account_id: user account id.
    """
    fmt = _("Here are FAQs about welfare and work support.")
    text = make_i18n_text("Here are FAQs about welfare and work support.",
                          "query_welfare", fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_welfare", "query_welfare",
                                      "Send a question", fmt)

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

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "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?"
    ]

    i18n_title_fmts = [
        _("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?")
    ]

    texts = [
        "Welfare includes the four main insurances, checkup, etc.",
        "A variety of club activities such as sports are supported.",
        "Contact the Work Support Team to request a company car.",
        "Visit the Work Support Team to receive office supplies."
    ]

    i18n_text_fmts = [
        _("Welfare includes the four main insurances, checkup, etc."),
        _("A variety of club activities such as sports are supported."),
        _("Contact the Work Support Team to request a company car."),
        _("Visit the Work Support Team to receive office supplies.")
    ]

    carousel = create_carousel("query_welfare",
                               labels,
                               POST_BACK_URLS["welfare"],
                               texts,
                               titles,
                               CAROUSEL["welfare"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
Ejemplo n.º 8
0
def storage_lack():
    fmt = _("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.")
    return make_i18n_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.", "message", fmt)
Ejemplo n.º 9
0
def create_articles_failed():
    fmt = _("Failed to complete posting. \n\n"
            "Ask the FAQ Ask Bot manager to check if the bulletin board number "
            "does not exist or if other items are set up incorrectly.")
    return make_i18n_text("Failed to complete posting. \n\n"
                          "Ask the FAQ Ask Bot manager to check if the bulletin"
                          " board number does not exist or if other items are "
                          "set up incorrectly.", "message", fmt)
Ejemplo n.º 10
0
def invalid_message():
    fmt = _("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.")

    return make_i18n_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.", "message", fmt)
Ejemplo n.º 11
0
def query_leave(account_id, __, ___):
    """
    This function deals with the problems related to leave query.

    :param account_id: user account id.
    """
    fmt = _("Here are FAQs about HR and leave.")
    text = make_i18n_text("Here are FAQs about HR and leave.", "query_leave",
                          fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_leave", "query_leave",
                                      "Send a question", fmt)

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

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "The types of leave.", "How many days of leave I have?",
        "To request a leave.", "To cancel my leave."
    ]

    i18n_title_fmts = [
        _("The types of leave."),
        _("How many days of leave I have?"),
        _("To request a leave."),
        _("To cancel my leave.")
    ]

    texts = [
        "Types of leave are classified in the Labor Standards Act.",
        "The remaining days of your leave are on in-house browser.",
        "You can request a leave via the in-house browser.",
        "You can cancel your leave request via the in-house browser."
    ]

    i18n_text_fmts = [
        _("Types of leave are classified in the Labor Standards Act."),
        _("The remaining days of your leave are on in-house browser."),
        _("You can request a leave via the in-house browser."),
        _("You can cancel your leave request via the in-house browser.")
    ]

    carousel = create_carousel("query_leave",
                               labels,
                               POST_BACK_URLS["leave"],
                               texts,
                               titles,
                               CAROUSEL["leave"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
Ejemplo n.º 12
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")

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

    fmt = _("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 = make_i18n_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.", "send", fmt)

    content1["quickReply"] = create_quick_replay()
    name, department = yield get_account_info(account_id)
    fmt = _("{department} {name} made an inquiry.")
    title = get_i18n_content_by_lang(fmt,
                                     "send",
                                     DEFAULT_LANG,
                                     department=department,
                                     name=name)
    prompt_message = yield create_articles(title, type, 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])
Ejemplo n.º 13
0
def enquire(account_id, __, ___):
    """
    This function handles the user's selection of ask a person

    :param account_id: user account id.
    """
    fmt = _("Select a task related to your question.")
    content = make_i18n_text("Select a task related to your question.",
                             "enquire", fmt)

    content["quickReply"] = create_quick_replay()

    yield push_message(account_id, content)
Ejemplo n.º 14
0
def query(account_id, __, ___):
    """
    This Function to deal "find FAQ" by task.
    :param account_id: user account id.
    """
    set_replace_user_info(account_id, "none", "doing", "none")
    fmt = _("Please select an work-related item that you would like to know.")
    content1 = make_i18n_text(
        "Please select an work-related item "
        "that you would like to know.", "query", fmt)

    content2 = template_introduce()

    yield push_messages(account_id, [content1, content2])
Ejemplo n.º 15
0
def query(account_id, __, ___):
    """
    This Function to deal "find FAQ" by task.
    :param account_id: user account id.
    """
    # todo
    # 此处查询用户的咨询状态,如果用户在
    fmt = _("Please select an work-related item that you would like to know.")
    content1 = make_i18n_text("Please select an work-related item "
                         "that you would like to know.", "query", fmt)

    content2 = template_introduce()

    yield push_messages(account_id, [content1, content2])
Ejemplo n.º 16
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")

    fmt = _("You have canceled your question. "
            "Please re-select the task from the menu below.")
    content = make_i18n_text("You have canceled your question. "
                             "Please re-select the task from the menu below.",
                             "cancel", fmt)
    clean_user_status(account_id)
    yield push_message(account_id, content)
Ejemplo n.º 17
0
def modify(account_id, __, ___):
    """
    This function handles the user's modification of the question

    :param account_id: user account id.
    """
    status, __, ___, ____ = get_user_status(account_id)
    if status != "done":
        raise HTTPError(500, "user status error. status error")

    fmt = _("I’ll help you modify your question. "
            "Please write your question again.")
    content = make_i18n_text(
        "I’ll help you modify your question. Please write"
        " your question again.", "modify", fmt)

    yield asyncio.sleep(0.5)

    set_user_status(account_id, status='wait_in')

    yield push_message(account_id, content)
Ejemplo n.º 18
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)
    fmt = _(
        "Do you want to send the following as your question? \n\n===\n{message}\n==="
    )
    content = make_i18n_text(text, "message", fmt, message=message)

    fmt0 = _("Send")
    action0 = make_i18n_postback_action("send", "message", "Send", fmt0,
                                        "Send", fmt0)
    item0 = make_quick_reply_item(action0)

    fmt1 = _("Modify")
    action1 = make_i18n_postback_action("modify", "message", "Modify", fmt1,
                                        "Modify", fmt1)
    item1 = make_quick_reply_item(action1)

    fmt2 = _("Cancel")
    action2 = make_i18n_postback_action("cancel", "message", "Cancel", fmt2,
                                        "Cancel", fmt2)
    item2 = make_quick_reply_item(action2)

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

    content["quickReply"] = quick_reply

    return content