Skip to content
QwryAI
Documentation
Pages

Guides

Conversation Search

Find an agent's conversations by what was said, or filter them by what happened, across every channel

Two tools find conversations from every channel: the Chat bubble, the API, WhatsApp, email and the rest. search_conversations finds conversations whose messages contain a phrase and shows you the matching line. query_conversations filters conversations by state, sentiment, feedback, channel, topic, contact and escalation. Both need a key with Manage conversations and helpdesk.

Quick start

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/search_conversations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "chatbotId": "YOUR_AGENT_ID",
    "query": "refund",
    "startDate": "2026-11-01",
    "endDate": "2026-11-30"
  }'
JSON
{
  "success": true,
  "data": {
    "items": [
      {
        "conversation": {
          "conversationId": "3c3766ae-0119-4687-b992-a7f6219d9b29",
          "channel": "whatsapp",
          "lifecycle": "open",
          "metadata": { "aiSummary": "Customer asks when the refund for order 1042 will arrive." },
          "timestamps": { "created": "2026-11-09T18:29:40.658Z", "lastActivity": "2026-11-09T18:41:02.114Z" },
          "metrics": { "messageCount": 8, "aiMessageCount": 4, "agentMessageCount": 0 },
          "insights": { "sentiment": "negative" }
        },
        "match": {
          "sender": "customer",
          "timestamp": "2026-11-09T18:32:37.261Z",
          "excerpt": "I returned the jacket last week, when will my refund for order 1042 come through?",
          "matchingMessages": 3,
          "customerMatches": 2
        }
      }
    ],
    "searchedConversations": 391,
    "conversationsInRange": 391,
    "range": { "startDate": "2026-11-01", "endDate": "2026-11-30" },
    "timezone": "UTC",
    "sender": "any",
    "coverage": "Case-insensitive literal match on customer, AI and agent message text in the 391 most recent conversations created in this range. Not semantic search."
  }
}

Each result pairs the conversation with its first matching message: who wrote it (customer, ai or agent), when, an excerpt, how many messages matched and how many of those the customer wrote.

Examples

To findTool and arguments
Conversations that mention refundssearch_conversations with "query": "refund"
What customers said about delivery, not what the agent saidsearch_conversations with "query": "delivery", "sender": "customer"
Conversations handed to a personquery_conversations with "escalated": true
Thumbs-down feedback on WhatsApp or the APIquery_conversations with "feedback": "bad", "sources": ["whatsapp", "api"]
Conversations a teammate took overquery_conversations with "activity_states": ["taken_over"]
Negative conversations about billingquery_conversations with "sentiment": ["negative"], "topic": "Billing"

Different filters must all match. Several values inside one list match any of them. The search phrase is matched as written, so refund chargeback only finds messages containing that exact phrase. To find either word, run two searches.

Filters

search_conversations:

ArgumentMatches
queryText in customer, AI or agent messages, 2 to 200 characters. Case-insensitive, matched as written; not semantic.
senderOnly messages from customer, ai or agent. Leave it out to match any.
topicConversations tagged with this topic.
startDate, endDateWhen the conversation was created, YYYY-MM-DD in UTC. Required.
limitResults to return, 1 to 50. Defaults to 20.

query_conversations:

ArgumentMatches
sourcesChannels, such as web, api, whatsapp or email
sentimentSentiment values, such as positive, neutral or negative
topic, topicsTopic names
activity_statesongoing, ended, taken_over, paused
feedbackgood or bad ratings
contactThe contact's name or email, matched as written
escalatedtrue for conversations escalated to a person, as in the Inbox Escalated view
startDate, endDateWhen the conversation was created. Required.
pageThe page, from 1. Required.

get_conversation_facets counts conversations in a range by sentiment, source, activity_state, topics and feedback, so you can see which filter values are in use.

Snippets

match.excerpt is the text of the first message that matched. match.sender says who wrote it. Use matchingMessages and customerMatches to rank results, for example to put conversations where the customer raised the topic several times first.

Reading a conversation

Search returns conversations without their messages. To read one, pass the conversation's _id (returned with each result) to get_conversation_detail:

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/get_conversation_detail' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "chatbotId": "YOUR_AGENT_ID",
    "conversationId": "CONVERSATION_RECORD_ID",
    "page": 1
  }'

It returns 20 messages per page, oldest first, as 800-character excerpts. Add "fullText": true for whole messages and "newestFirst": true to start from the latest.

Paging

search_conversations returns one list, up to limit results; there are no further pages. query_conversations is paged: keep every argument the same, raise page, and stop when hasMore is false.

JavaScript
const conversations = [];
let page = 1;
let hasMore = true;

while (hasMore) {
  const response = await fetch(
    "https://api.qwryai.com/public/v1/tools/query_conversations",
    {
      method: "POST",
      headers: { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" },
      body: JSON.stringify({
        chatbotId: "YOUR_AGENT_ID",
        startDate: "2026-11-01",
        endDate: "2026-11-30",
        escalated: true,
        page,
      }),
    }
  );
  const { data } = await response.json();
  conversations.push(...data.items);
  hasMore = data.hasMore;
  page += 1;
}
Python
import requests

conversations = []
page = 1
while True:
    response = requests.post(
        "https://api.qwryai.com/public/v1/tools/query_conversations",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={
            "chatbotId": "YOUR_AGENT_ID",
            "startDate": "2026-11-01",
            "endDate": "2026-11-30",
            "escalated": True,
            "page": page,
        },
    )
    data = response.json()["data"]
    conversations.extend(data["items"])
    if not data["hasMore"]:
        break
    page += 1

Limits

  • 184 days per call. startDate and endDate can be at most 184 days apart. Read longer periods as several ranges.
  • 2,000 conversations per search. search_conversations looks through the 2,000 most recent conversations created in the range. searchedConversations and conversationsInRange tell you whether it covered them all; if not, shorten the range.
  • Text, not meaning. The search matches the words you send, not similar wording.
  • 40,000 bytes per response. A larger result returns 413 RESULT_TOO_LARGE; lower limit or shorten the range.
  • Permissions. The key needs Manage conversations and helpdesk.

MCP

The QwryAI MCP server offers the same search_conversations, query_conversations and get_conversation_detail tools to AI assistants such as Claude, with the same arguments and limits.

Error codes

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

CodeHTTPDescription
INVALID_ARGUMENTS400A required argument is missing or out of range, such as a query under 2 characters or a date not written YYYY-MM-DD.
VALIDATION_INVALID_BODY409The dates aren't real days, the end is before the start, or they're more than 184 days apart.
INSUFFICIENT_PERMISSION403The key doesn't hold Manage conversations and helpdesk.
RESULT_TOO_LARGE413The result is over 40,000 bytes. Lower limit or shorten the range.

Explore the documentation