Sign in

Process Zendesk ticket

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
import json print(json.dumps(ticket, indent=4)) TICKET_ID_TO_UPDATE = ticket['id'] cred_label = "zendesk_cred" latest_comment = ticket["latest_comment"]
copied
  1. 1

    Extract an IPv4 address from text

    There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
    import re def extract_ipv4(text): pattern = re.compile(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b") ipv4_addresses = pattern.findall(text) return ipv4_addresses op = extract_ipv4(text) if op: print(op) ipv4_address = op else: context.proceed = False
    copied
    1
  2. 2

    Do basic health check on a server

    There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
    op = "```\n" op += "Memory check: \n" op += _exe(host, "free") op += "\n\n" op += "CPU check: \n" op += _exe(host, "top -b -n 1 | grep Cpu") op += "\n\n" op += "Disk check: \n" op += _exe(host, "df /") op += "\n" op += "```" health_check_summary = op print(op)
    copied
    2
  3. 3

    Add a private comment to a Zendesk ticket

    There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

    This task is designed to append a non-public, internal comment to a specific Zendesk ticket, facilitating internal team communications and notes without exposing the information to the ticket requester.

    import zenpy from zenpy.lib.exception import ZenpyException # Credentials for Zendesk API creds = _get_creds(cred_label)['creds'] ZENDESK_EMAIL = creds['username'] ZENDESK_TOKEN = creds['password'] #TICKET_ID_TO_UPDATE = '3' # Replace with your ticket ID UPDATE_FIELDS = { 'comment': comment # Add other fields as needed } # Initialize Zenpy client client = zenpy.Zenpy(email=ZENDESK_EMAIL, token=ZENDESK_TOKEN, subdomain=ZENDESK_SUBDOMAIN) def update_ticket(ticket_id, update_fields): """ Update a Zendesk ticket with the given fields. Parameters: - ticket_id: The ID of the ticket to update. - update_fields: A dictionary containing the fields to update, including comments. """ try: # Retrieve the ticket by ID ticket = client.tickets(id=ticket_id) # Update fields of the ticket for key, value in update_fields.items(): if key.lower() == 'subject': ticket.subject = value elif key.lower() == 'comment': # Special handling for comments ticket.comment = zenpy.lib.api_objects.Comment(body=value, public=False) # Add other fields handling as needed # Update the ticket in Zendesk client.tickets.update(ticket) return True except ZenpyException as e: print(f"ZenpyException occurred: {e}") return False except Exception as e: print(f"An error occurred: {e}") return False # Update the ticket if update_ticket(TICKET_ID_TO_UPDATE, UPDATE_FIELDS): print(f"Ticket {TICKET_ID_TO_UPDATE} updated successfully.") else: print("Failed to update ticket.")
    copied
    3