Recent searches


No recent searches

Zendesk API: Count tickets requested by user



Posted Jun 29, 2022

Hello,

I'm trying to create a personalized help-center for our users and I was trying to leverage Zendesk API for that.

 

I want to list all tickets requested by a user (our customer and not our agent). In the front-end, I was trying to create a pagination, so I'm leveraging this endpoint: https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#count-tickets. However, I'm not seeing a `tickets/requested/count` endpoint.

 

The end goal I'm trying to achieve is allow a deterministic pagination in the front-end. For example, if a user has requested 10 tickets, and I'm paginating 2 tickets per API call, I still wish to show the user that there would be 5 total pages. This would be preferable over showing something like "load older tickets" for an indeterminate number.

 

Is there some value I can access? I can use a recursive function to fetch all tickets and count them, but that's an overkill and would not want to waste a network overhead + time to response if the user would never check the 10th ticket.

 

I'm sorting the tickets by their ID (descending), if it makes a difference.

 

Could someone please point me in the right direction?


0

2

2 comments

image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Hrishikesh! Thanks for sharing the intended use-case for this, because I don't have a solution based on the way you were approaching this, but I do believe I have one in a slightly different way. I'm assuming that based on the way that this was worded, you're not using Zendesk's built-in functionality with Guide and instead want a custom solution for this. 

When it comes to the end-user's perspective, rather than the various ticket endpoints, you would actually want to utilize the requests endpoints instead. Specifically, you'd want to use one of the various List Requests methods, along with an OAuth token, scoped with "impersonate". This will be a lightweight solution, since the tickets that you will be pulling will only be from the signed-in user, and you can further filter it down to ticket status. It also provides sorting right there, so you wouldn't have to do any extra work with that.

Let us know if you have any questions about this!

0


Hi Greg Katechis

Thank you for sharing this. You're right, I'm not using Zendesk's built-in functionality.

About the list requests method, that still doesn't seem to provide the total count, correct? I tried to read more on it, but didn't seem to find it, so wanted to confirm.

About the OAuth method, unfortunately, that doesn't seem to be possible in our current setup. We're using helpdesk only for the agent and our users do not have any passwords or logins to check the ticket status. That's totally handled via emails. So, we won't be able to leverage Zendesk OAuth there. Thanks for suggesting though, in case we change our setup, this would be helpful. In the meantime, I'd continue to rely on users/id/tickets/requested and same for organizations.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post