PenfieldAssign

PenfieldAssign will use the Penfield.AI integration's penfield-get-assignee command to determine who an incident should be assigned to, then print the selected analyst to the War Room and overwrite the owner property.

python · PenfieldAI

Source

import traceback

import demistomock as demisto
from CommonServerPython import *

# from CommonServerPython import return_results, return_error
from CommonServerUserPython import *

""" COMMAND FUNCTION """


def penfield_assign(analyst_ids, category, created, id, name, severity):
    return demisto.executeCommand(
        "penfield-get-assignee",
        {"analyst_ids": analyst_ids, "category": category, "created": created, "id": id, "name": name, "severity": severity},
    )


""" MAIN FUNCTION """


def main():
    try:
        assign = demisto.args()["assign"]

        # get online analyst ids
        analysts = demisto.executeCommand("getUsers", {"online": True})[0]["Contents"]
        usernames = [a["username"] for a in analysts]
        analyst_ids = ""
        analyst_ids += ",".join(usernames)

        # get relevant incident information
        incident = demisto.incidents()[0]
        category = incident["category"]
        created = incident["created"]
        id = incident["id"]
        name = incident["name"]
        severity = incident["severity"]

        # get assignee
        chosen_one = penfield_assign(analyst_ids, category, created, id, name, severity)[0]["Contents"]

        # perform action & return response
        if assign == "Yes":
            demisto.executeCommand("setOwner", {"owner": chosen_one})
            return_results("incident assigned to: " + chosen_one)
        else:
            return_results("penfield suggests: " + chosen_one)

    except Exception as ex:
        demisto.error(traceback.format_exc())  # print the traceback
        return_error(ex)


""" ENTRY POINT """


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()

README

PenfieldAssign will use the PenfieldGetAssignee integration to determine who an incident should be assigned to, then print the selected analyst to the War Room and overwrite the owner property.

Script Data


Name Description
Script Type python3
Tags management, user, Utility
Cortex XSOAR Version 5.5.0

Dependencies


This script uses the following commands and scripts.

  • penfield-api-call

Inputs


Argument Name Description
assign Whether this script should actually assign the incident by overwriting owner. Defaults to yes.

Outputs


There are no outputs for this script.

Examples


!PenfieldAssign
!PenfieldAssign assign=’Yes’
!PenfieldAssign assign=’No’

Human Readable Output

incident assigned to: charles