List All Conversations of a Ticket, order by?

Hello,


I was wondering if there is any way by calling the Freshdesk API, with the following URL:

/api/v2/tickets/[id]/conversations

To sort the conversation by creation date by DESC?

I am aware that the API Docs don't describe the issue.


The use case is that, we are trying to make a virtual scroller for conversation paggination.

Is this even possible with current API?


2 people have this question

I agree! I don't see any benefits from the current (ascending only) order. People mostly want to see THE LATEST CONVERSATION on the ticket and there is not any other solution than pagination which is complicated and generates useless requests which should not in the Freshworks' interests as it consumes their server resources.

So this was how I resolved this issue, the code below will run through and combine all the conversations pages (if multiples exist) and then sort the final array in data DESC order.


  

  async getAllConversations() {
    let loop = true;
    let page = 1;
    let result: any;
    let conversations: any[] = [];

    while (loop) {
      result = await this.getConversationsPage(page);
      conversations = conversations.concat(result);
      page ++;
      if (result.length != 30) {
        loop = false;
      }
    }
    conversations = conversations.filter(c => !c.private);
    conversations.sort((a, b) => (new Date(a.updated_at) > new Date(b.updated_at)) ? -1 : 1);
    return conversations;
  }

  getConversationsPage(page: number) {
    return this._freshdeskService.getTicketConversations(this.ticketId, page).toPromise();
  }

  

Login or Signup to post a comment