qNh0N9JHoM2WjPWV3zbIProcess Zendesk Ticket for updating comments (auto reply)
Process Zendesk Ticket for updating comments (auto reply)
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
inputs
outputs
import json
print(json.dumps(ticket, indent=4))
cred_label ="your_cred_label" # Type in your Zendesk Cred Label created on the proxy
subdomain = "your_subdomain"
TICKET_ID_TO_UPDATE = ticket['id']
print(f"Printing TICKET_ID_TO_UPDATE: {TICKET_ID_TO_UPDATE}")
#latest_comment = ticket["latest_comment"]
copied
- 1TQ8GwIzgO7QuzwoL9hIDAdd a private comment to tickets containing "forensics:" in public comment and add tag "answered"
1
Add a private comment to tickets containing "forensics:" in public comment and add tag "answered"
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.We are adding the tag "answered" to avoid trigger loop conditions. Otherwise the trigger will run indefinitely till it reads the comment forensics: in the ticket comments.
inputsoutputsimport zenpy from zenpy.lib.exception import ZenpyException # Credentials for Zendesk API creds = _get_creds(cred_label)['creds'] # Assuming the function _get_creds retrieves the necessary credentials ZENDESK_EMAIL = creds['username'] ZENDESK_TOKEN = creds['password'] ZENDESK_SUBDOMAIN = subdomain # Replace with your subdomain # Initialize Zenpy client client = zenpy.Zenpy(email=ZENDESK_EMAIL, token=ZENDESK_TOKEN, subdomain=ZENDESK_SUBDOMAIN) def update_ticket_with_public_comment_and_tag(ticket_id, update_fields): """ Update a Zendesk ticket with a public comment and add a specific tag. Parameters: - ticket_id: The ID of the ticket to update. - update_fields: A dictionary containing the fields to update, including the comment. """ 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=True) # Set comment to public # Add the "answered" tag to the ticket if 'answered' not in ticket.tags: ticket.tags.append('answered') # 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 # Example usage #TICKET_ID_TO_UPDATE = '3' # Replace with your ticket ID UPDATE_FIELDS = { 'comment': "Reply back to forensics: keyword and appending the tag answered" # Replace with your comment # Add other fields as needed } # Update the ticket with a public comment and add the 'answered' tag if update_ticket_with_public_comment_and_tag(TICKET_ID_TO_UPDATE, UPDATE_FIELDS): print(f"Ticket {TICKET_ID_TO_UPDATE} updated with a public comment and tagged 'answered' successfully.") else: print("Failed to update ticket with a public comment and tag.")copied1