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
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"
}'{
"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 find | Tool and arguments |
|---|---|
| Conversations that mention refunds | search_conversations with "query": "refund" |
| What customers said about delivery, not what the agent said | search_conversations with "query": "delivery", "sender": "customer" |
| Conversations handed to a person | query_conversations with "escalated": true |
| Thumbs-down feedback on WhatsApp or the API | query_conversations with "feedback": "bad", "sources": ["whatsapp", "api"] |
| Conversations a teammate took over | query_conversations with "activity_states": ["taken_over"] |
| Negative conversations about billing | query_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:
| Argument | Matches |
|---|---|
query | Text in customer, AI or agent messages, 2 to 200 characters. Case-insensitive, matched as written; not semantic. |
sender | Only messages from customer, ai or agent. Leave it out to match any. |
topic | Conversations tagged with this topic. |
startDate, endDate | When the conversation was created, YYYY-MM-DD in UTC. Required. |
limit | Results to return, 1 to 50. Defaults to 20. |
query_conversations:
| Argument | Matches |
|---|---|
sources | Channels, such as web, api, whatsapp or email |
sentiment | Sentiment values, such as positive, neutral or negative |
topic, topics | Topic names |
activity_states | ongoing, ended, taken_over, paused |
feedback | good or bad ratings |
contact | The contact's name or email, matched as written |
escalated | true for conversations escalated to a person, as in the Inbox Escalated view |
startDate, endDate | When the conversation was created. Required. |
page | The 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:
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.
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;
}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 += 1Limits
- 184 days per call.
startDateandendDatecan be at most 184 days apart. Read longer periods as several ranges. - 2,000 conversations per search.
search_conversationslooks through the 2,000 most recent conversations created in the range.searchedConversationsandconversationsInRangetell 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; lowerlimitor 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:
| Code | HTTP | Description |
|---|---|---|
INVALID_ARGUMENTS | 400 | A 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_BODY | 409 | The dates aren't real days, the end is before the start, or they're more than 184 days apart. |
INSUFFICIENT_PERMISSION | 403 | The key doesn't hold Manage conversations and helpdesk. |
RESULT_TOO_LARGE | 413 | The result is over 40,000 bytes. Lower limit or shorten the range. |