Get Message History
User Intent
"I want to retrieve the complete message history from a conversation"
Operation
SDK Method:
graphlit.getConversation()GraphQL:
getConversationqueryEntity Type: Conversation
Common Use Cases: View chat history, export conversations, display message thread
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { Types } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
const conversationId = 'conversation-id-here';
// Get conversation with full message history
const conversation = await graphlit.getConversation(conversationId);
console.log(`\nConversation: ${conversation.conversation.name}`);
console.log(`Total messages: ${conversation.conversation.messages?.length || 0}\n`);
// Display message history
conversation.conversation.messages?.forEach((msg, index) => {
console.log(`${index + 1}. [${msg.role}] ${msg.timestamp}`);
console.log(msg.message);
// Show citations if available
if (msg.citations && msg.citations.length > 0) {
console.log(`\nCitations:`);
msg.citations.forEach((citation, citIndex) => {
console.log(` [${citIndex + 1}] ${citation.content?.name}`);
});
}
console.log('---\n');
});Parameters
id(string): Conversation ID
Response
Developer Hints
Filter by Role
Export Conversation
Last updated
Was this helpful?