最近搜索
没有最近搜索

Support team
已加入2021年10月16日
·
最后活动2023年10月10日
关注
1
关注者
1
活动总数
55
投票
25
订阅
14
活动概览
标记
文章
帖子
社区评论
文章评论
活动概览
的最新活动 Support team
Support team 创建了一个帖子,
Deleting a lot of tickets from your Zendesk instance can be a daunting task, especially if you have thousands of tickets that need to be removed. Fortunately, using Python and the Zendesk API, you can automate this process and save yourself a lot of time and effort.
Here are some tips and tricks to help you delete a lot of tickets from your Zendesk instance using Python and the Zendesk API:
-
Use the Zendesk API to retrieve the list of tickets that you want to delete. You can use filters to narrow down the list of tickets based on certain criteria, such as their status, tags, or creation date.
-
Once you have retrieved the list of tickets, loop through it and delete each ticket using the Zendesk API. Make sure to use the bulk delete endpoint to delete multiple tickets at once, as this will save you a lot of time.
-
Keep track of the progress of the deletion process by printing out the number of tickets that have been deleted and the number of tickets that are still left to delete. This will help you monitor the process and ensure that everything is going smoothly.
-
If you encounter any errors or issues during the deletion process, use the error handling mechanisms in Python to handle them gracefully. For example, you could log the error messages to a file or send them to an email address for further analysis.
-
Finally, test your Python script on a small subset of tickets before running it on your entire Zendesk instance. This will help you identify any issues or unexpected behavior before you start deleting a large number of tickets.
In conclusion, using Python and the Zendesk API to delete a lot of tickets from your Zendesk instance can be a powerful way to automate a tedious and time-consuming task. By following these tips and tricks, you can ensure that the process goes smoothly and that your Zendesk instance stays clean and organized.
Here is the code I used:
import requests import time import base64 # Replace with your Zendesk subdomain and API credentials SUBDOMAIN = 'HERE' #add subdomain here EMAIL = 'user@domain.com' #add email here api key here API_KEY = '' #add api key here # Read the ticket IDs from a text file, one ID per line with open('ticket_ids.txt', 'r') as f: ticket_ids = f.read().splitlines() # Set the maximum number of tickets to delete per API request MAX_TICKETS_PER_REQUEST = 99 # Split the ticket IDs into batches of maximum size MAX_TICKETS_PER_REQUEST ticket_id_batches = [ticket_ids[i:i+MAX_TICKETS_PER_REQUEST] for i in range(0, len(ticket_ids), MAX_TICKETS_PER_REQUEST)] # Set up the API request headers with Basic authentication headers = { 'Content-Type': 'application/json', 'Authorization': f'Basic {base64.b64encode(f"{EMAIL}/token:{API_KEY}".encode("utf-8")).decode("ascii")}', } total_deleted_tickets = 0 last_successful_ticket_id = None # Loop over each ticket ID batch and delete the tickets for ticket_ids_batch in ticket_id_batches: # Construct the URL to delete the tickets url = f'https://{SUBDOMAIN}.zendesk.com/api/v2/tickets/destroy_many.json?ids={",".join(ticket_ids_batch)}' # Send the API request to delete the tickets with timeout of 60 seconds response = requests.delete(url, headers=headers, timeout=60) # Check if the request was successful if response.status_code == 200: num_deleted_tickets = len(ticket_ids_batch) total_deleted_tickets += num_deleted_tickets last_successful_ticket_id = ticket_ids_batch[-1] print(f'{num_deleted_tickets} tickets deleted successfully. Total deleted: {total_deleted_tickets}.') else: error_ticket_id = None if len(ticket_ids_batch) == 1: error_ticket_id = ticket_ids_batch[0] else: # Find the first ticket ID in the batch that was not deleted successfully response_json = response.json() for ticket_id in ticket_ids_batch: if str(ticket_id) not in response_json['results']: error_ticket_id = ticket_id break print(f'Error deleting tickets. Last successful ticket ID: {last_successful_ticket_id}. Error ticket ID: {error_ticket_id}. Response: {response.text}') break # Print a loader to indicate that the code is still running for i in range(5): print('.', end='', flush=True) time.sleep(1) print() # Wait for 10 seconds before sending the next request time.sleep(10)
I added a new variable last_successful_ticket_id to keep track of the ID of the last ticket that was deleted successfully. If an error occurs during the deletion of a batch of tickets, the code will print the ID of the last successful ticket and the ID of the ticket where the error occurred.
Note that if a batch contains only one ticket and an error occurs, the code will assume that the error occurred with that ticket. Otherwise, it will check the API response to determine which ticket in the batch was not deleted successfully. If an error occurs, the code will break out of the loop and stop deleting tickets, so you will need to manually modify the list of ticket IDs to start from the last successful ticket ID and run the code again.
You can use it as is for our own purposes.
已于 2023年3月10日 发布 · Support team
5
关注者
4
投票
1
Comment
Support team 创建了一个帖子,
Hello Zendesk Team!
Most of our agents work simultaneously with several chats, over time this number can reach up to 8. But in the agent workspace interface, after opening more than 4-5 chats, they are minimized and you can see them all only by clicking on the "More" button. This is not very convenient.
Are you considering flexible layout for chats?
Thank you!
已于 2022年3月21日 发布 · Support team
4
关注者
4
投票
2
评论
Support team 创建了一个帖子,
Hello, Zendesk Team!
Our team leads in the old version of chats (not in the agent workspace) had the rights to ban a user in the chat - directly from the chat window. When switching to agent workspace , this feature was lost, leaving only the ability to ban a user by IP address. But this is very inconvenient and does not always work correctly.
In ticket #10087547 we got the final answer about ban users: "In the agent workspace, we can not ban users, only through the IP address."
Do you plan to add the ability to quickly ban users directly in chats/messaging in agent workspace?
已于 2022年3月17日 发布 · Support team
19
关注者
23
投票
13
评论
Support team 创建了一个帖子,
Hello, Zendesk Team!
In our agents workflow - we need to create follow up ticket after the ticket was solved in Agent
Workspace. (Btw this article is already read)
In old version of chats, we can create tickets directly and assign ignt them to another agent.
In Agent workspace, we only can create follow-up after the ticket is solved.
Do you plan to add the ability to quickly create a follow up ticket (with ticket history) to assign it to another agent?
已于 2022年3月17日 发布 · Support team
4
关注者
4
投票
1
Comment
Support team 进行了评论,
Hi Dan Nolan !
Thank you for reply. "Five Most Recent" app work normally with customers without emails (I think no)?
I'm looking to zendesk external_id , but Zendesk doesn't give to me any cases about using external_in. "Just go to read manuals"
查看评论 · 已于 2022年1月28日 发布 · Support team
0
关注者
0
投票
0
评论