Query and List Conversations

User Intent

"I want to list all my conversations or find a specific conversation by name"

Operation

  • SDK Method: graphlit.queryConversations() or graphlit.getConversation()

  • GraphQL: queryConversations or getConversation query

  • Entity Type: Conversation

  • Common Use Cases: List conversations, find conversation by name, retrieve conversation history, manage conversations

TypeScript (Canonical)

import { Graphlit } from 'graphlit-client';
import { EntityState } from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Query all conversations
const allConversations = await graphlit.queryConversations();

console.log(`Total conversations: ${allConversations.conversations.results.length}`);

allConversations.conversations.results.forEach(conv => {
  console.log(`- ${conv.name} (${conv.state})`);
  console.log(`  Messages: ${conv.messages?.length || 0}`);
});

// Search by name
const searchResults = await graphlit.queryConversations({
  search: 'Support Chat'
});

console.log(`\nFound ${searchResults.conversations.results.length} matching conversations`);

// Get specific conversation with full details
const conversationId = 'conversation-id-here';
const conversation = await graphlit.getConversation(conversationId);

console.log(`\nConversation: ${conversation.conversation.name}`);
console.log(`Created: ${conversation.conversation.creationDate}`);
console.log(`Messages: ${conversation.conversation.messages?.length || 0}`);

// Print message history
conversation.conversation.messages?.forEach((msg, index) => {
  console.log(`\n${index + 1}. ${msg.role}:`);
  console.log(msg.message);
});

Parameters

queryConversations (Optional Filter)

  • search (string): Search by conversation name

  • states (EntityState[]): Filter by state

    • ENABLED, DISABLED

getConversation (Required)

  • id (string): Conversation ID

Response

queryConversations

getConversation

Developer Hints

Conversation History Access

Important: Only getConversation() returns full message history. queryConversations() returns summaries.

Find Conversation by Name

Resume Conversation

Conversation Statistics

Variations

1. List All Conversations

Get all conversations:

2. Search by Name

Find specific conversations:

3. Get Full Conversation History

Retrieve with messages:

4. Filter Active Conversations

Only enabled conversations:

5. Recent Conversations

Sort by creation date:

6. Conversation with Citations

Get conversation with citation tracking:

Common Issues

Issue: Conversation not found error Solution: Verify conversation ID is correct. Conversation may have been deleted. Use queryConversations() to list all.

Issue: No message history returned Solution: Use getConversation() not queryConversations(). Only getConversation() includes full messages.

Issue: Search returns no results Solution: Search is case-sensitive. Try partial matches. Use queryConversations() without filter to see all.

Issue: Old conversations appearing Solution: Conversations persist indefinitely. Use deleteConversation() to clean up old ones.

Production Example

Conversation history viewer:

Resume or create conversation:

Conversation management dashboard:

Last updated

Was this helpful?