Skip to content
QwryAI
Documentation
Pages

Guides

Helpdesk

Read and search your agent's tickets, and manage Helpdesk statuses, teams, rules and macros from code

The helpdesk tools work on the same tickets your team handles under Tickets in the dashboard. You can list and filter tickets, search them by number, title or customer, read a ticket with its comments, and pull counts and analytics into your own reports. With a settings key you can also manage the Helpdesk itself: ticket statuses, teams, triggers, automations, macros, tags, shifts and webhooks.

Tickets are numbered per workspace as TKT-1, TKT-2 and so on. Tools that read one ticket take that number as ticketId. A ticket's source records where it started, such as chat or a connected helpdesk like freshdesk.

Statuses

Each ticket's status belongs to one of six fixed categories: open, in_progress, on_hold, waiting_on_customer, resolved and closed. Inside each category you can add your own statuses in Settings › Helpdesk › Statuses; one per category is the default.

ToolDoes
query_tickets with statusFilters tickets by category.
get_ticket_countsCounts tickets by current status, plus unassigned tickets.
get_helpdesk_page with "page": "statuses"Lists the statuses with their ticket counts.
save_ticket_statusAdds a status, or renames, describes, archives or makes one the default. customer_name is the name customers see.
reorder_ticket_statusesReorders one category's statuses.

Assignment and routing

query_tickets filters by assigneeId or "unassigned": true, never both at once. Each ticket returns assignedAgentId and assignedAgentName. list_helpdesk_agents lists the members tickets can be assigned to.

Routing is set up as Helpdesk rules rather than per ticket:

ToolDoes
save_helpdesk_teamAdds or changes a team: its members, assignment strategy (manual, round_robin or balanced), workload limit and default.
save_helpdesk_ruleAdds or changes a trigger or automation, with its conditions and actions.
set_helpdesk_rule_enabledTurns a trigger or automation on or off.
save_helpdesk_shift, assign_helpdesk_shift, save_time_offWorking hours and time off.

Reading these settings needs Manage conversations and helpdesk. Changing them needs Change agent settings, and like every change they return a review you apply. See Agents › Reviewed updates.

Messages

get_ticket_detail returns a ticket with its description and its comments in pages. Start with "offset": 0 and continue with the nextOffset it returns until that's null. Internal comments are included for members whose role can see them.

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/get_ticket_detail' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"chatbotId": "YOUR_AGENT_ID", "ticketId": "TKT-73", "offset": 0}'
JSON
{
  "success": true,
  "data": {
    "ticketId": "TKT-73",
    "source": "chat",
    "assignedAgentId": null,
    "assignedAgentName": null,
    "title": "Late delivery for order 1043",
    "category": "general",
    "priority": "medium",
    "status": "open",
    "timestamps": { "created": "2026-11-30T18:15:02.074Z", "updated": "2026-11-30T18:56:55.709Z", "assigned": null, "resolved": null, "closed": null },
    "respondedAt": null,
    "description": "My delivery for order 1043 is two weeks late. Please help me resolve this.",
    "descriptionTruncated": false,
    "comments": [],
    "nextOffset": null
  }
}

The ticket tools read; they don't reply. To answer the customer from code, reply in the ticket's conversation with send_agent_message, which takes the conversation over for the key's creator, or add a private add_internal_note.

Searching and reporting

ToolReturns
query_ticketsTickets, 20 per page, filtered by status, assignee, channel, creation dates and title text. view_id applies a saved view.
search_ticketsUp to 20 tickets matching a ticket number, title or description, or ("filter": "customers") the customers who opened tickets, by name, email, phone or company.
list_saved_viewsYour ticket views, as the Tickets sidebar shows them.
list_tags, list_custom_fieldsThe agent's ticket tags and custom fields.
get_helpdesk_overviewDaily ticket volume, sources, statuses and resolutions for a date range.
get_ticket_resolution_analyticsDaily resolutions and average resolution time.
get_agent_performanceReplies, notes, resolutions and assignments per team member.

Access

Every ticket tool needs Manage conversations and helpdesk. Reading Helpdesk settings needs the same; changing them needs Change agent settings. A key never does more than its creator's role allows.

Paging

query_tickets pages by number: raise page until hasMore is false. Date filters need both startDate and endDate, written YYYY-MM-DD. See Pagination.

Pull yesterday's tickets every day

JavaScript
const yesterday = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
const tickets = [];
let page = 1;
let hasMore = true;

while (hasMore) {
  const response = await fetch("https://api.qwryai.com/public/v1/tools/query_tickets", {
    method: "POST",
    headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
    body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", startDate: yesterday, endDate: yesterday, page }),
  });
  const { data } = await response.json();
  tickets.push(...data.items);
  hasMore = data.hasMore;
  page += 1;
}

console.log(`${tickets.length} tickets opened yesterday`);

Endpoints

Error codes

Helpdesk-specific error codes beyond the standard authentication and rate-limiting errors:

CodeHTTPDescription
INVALID_ARGUMENTS400An argument failed the tool's schema, such as an unknown status.
VALIDATION_INVALID_BODY409Only one of startDate and endDate was sent, both assigneeId and unassigned were sent, or view_id doesn't match a saved view.
INSUFFICIENT_PERMISSION403The key doesn't hold Manage conversations and helpdesk, or Change agent settings for a settings change.
CHATBOT_NOT_FOUND404No agent with that chatbotId in your workspace.

Explore the documentation