# CLI Tickets > List, search and read a QwryAI agent's Helpdesk tickets, and look up its ticket statuses and teams from the terminal Use the ticket tools to triage your Helpdesk from a script: list tickets by status or assignee, search them, read a ticket with its comments, and look up the statuses and teams they use. They need the **Manage conversations and helpdesk** permission. Sign in first (see [CLI Auth](/docs/cli/auth)) and keep the agent's id in `$AGENT` (see [CLI Agents](/docs/cli/agents)). ## List and search tickets List the agent's tickets, newest first, twenty per page: ```bash qwryai-cli tools:call query_tickets --args "{\"chatbotId\":\"$AGENT\",\"page\":1}" ``` ```json { "success": true, "data": { "items": [ { "_id": "", "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 } ], "total": 270, "page": 1, "hasMore": true, "searchMode": "literal_title" } } ``` Filter by status, assignee, channel or creation date: ```bash qwryai-cli tools:call query_tickets --args "{\"chatbotId\":\"$AGENT\",\"page\":1,\"status\":\"open\",\"unassigned\":true,\"startDate\":\"2026-11-01\",\"endDate\":\"2026-11-30\"}" ``` `status` is one of `open`, `in_progress`, `on_hold`, `waiting_on_customer`, `resolved` or `closed`. Use `assigneeId` for one member's tickets, `channel` for one source, `search` to match titles, and `view_id` to apply a saved view from `list_saved_views`. Give both dates or neither. Search tickets by ticket ID, title or description: ```bash qwryai-cli tools:call search_tickets --args "{\"chatbotId\":\"$AGENT\",\"query\":\"order 1043\"}" ``` Add `"filter":"customers"` to search the people who opened tickets by name, email, phone or company instead. Count tickets by status, with how many are unassigned: ```bash qwryai-cli tools:call get_ticket_counts --args "{\"chatbotId\":\"$AGENT\"}" ``` ```json {"success":true,"data":{"rows":[{"_id":"open","count":232,"unassigned":212},{"_id":"in_progress","count":2,"unassigned":0},{"_id":"resolved","count":28,"unassigned":12}]}} ``` ## Get a ticket and read comments Show one ticket by its number, with its description and comments: ```bash qwryai-cli tools:call get_ticket_detail --args "{\"chatbotId\":\"$AGENT\",\"ticketId\":\"TKT-73\",\"offset\":0}" ``` ```json { "success": true, "data": { "ticketId": "TKT-73", "source": "chat", "title": "Late delivery for order 1043", "priority": "medium", "status": "open", "assignedAgentName": null, "timestamps": { "created": "2026-11-30T18:15:02.074Z", "updated": "2026-11-30T18:56:55.709Z" }, "description": "Hello support team, my delivery for order 1043 is two weeks late. Please help me resolve this. Best regards, Sam Tester", "descriptionTruncated": false, "comments": [], "nextOffset": null } } ``` Comments come in pages; when `nextOffset` isn't `null`, call again with that `offset`. Internal comments are included for members allowed to see them. > [!NOTE] > > The ticket tools only read. To answer a customer in a chat, reply in the conversation with `send_agent_message`; see [CLI Conversations](/docs/cli/conversations). ## Look up statuses and teams List the ticket statuses, with their names in the Helpdesk, the names customers see, and ticket counts: ```bash qwryai-cli tools:call get_helpdesk_page --args "{\"chatbotId\":\"$AGENT\",\"page\":\"statuses\"}" ``` ```json { "success": true, "data": { "page": "statuses", "settings": { "statuses": [ { "id": "open", "category": "open", "name": "New", "customerName": "Submitted", "description": "", "isDefault": true, "archived": false }, { "id": "in_progress", "category": "in_progress", "name": "On you", "customerName": "In progress", "description": "", "isDefault": true, "archived": false }, { "id": "resolved", "category": "resolved", "name": "Closed", "customerName": "Resolved", "description": "", "isDefault": true, "archived": false } ], "ticketCounts": { "open": 232, "in_progress": 2, "resolved": 28 } } } } ``` List the Helpdesk teams, including the default one: ```bash qwryai-cli tools:call get_helpdesk_page --args "{\"chatbotId\":\"$AGENT\",\"page\":\"teams\"}" ``` ```json {"success":true,"data":{"page":"teams","settings":[{"name":"General","strategy":"manual","maxTicketsPerAgent":null,"workloadCategories":["open","in_progress"],"unassignOnReply":false,"id":"","isDefault":true,"memberIds":[],"lastAssignedId":null,"openTickets":25,"unassignedTickets":18}]}} ``` The same tool reads the other **Settings › Helpdesk** pages too: `members`, `scheduling`, `triggers`, `automations`, `macros`, `ticket_reuse`, `translation`, `ai_draft` and `csat`. > [!TIP] > > Use `jq` to turn statuses into a lookup table for scripts: `jq '.data.settings.statuses | map({(.id): .name}) | add'`. ## Commands | Tool | Purpose | | - | - | | `query_tickets` | List tickets, with status, assignee, channel, date and title filters | | `search_tickets` | Search tickets by ID, title or description, or the customers who opened them | | `get_ticket_counts` | Count tickets by status, with unassigned counts | | `get_ticket_detail` | Show one ticket with its description and comments | | `list_saved_views` | List saved ticket views to use as `view_id` | | `get_helpdesk_page` | Read ticket statuses, teams and other Helpdesk settings | | `get_ticket_resolution_analytics` | Count resolved tickets per day and the average hours to resolve, for a date range | > [!NOTE] > > These tools read the QwryAI Helpdesk only. Tickets in an external helpdesk such as Zendesk aren't covered.