Managing conversations with R2R.

This feature is currently in beta. Functionality may change, and we value your feedback around these features.

Occasionally this SDK documentation falls out of date, cross-check with the automatically generated API Reference documentation for the latest parameters.

Conversation Management

Get Conversations Overview

Retrieve an overview of existing conversations:

1const offset = 0;
2const limit = 10;
3const overviewResponse = await client.conversationsOverview(offset, limit);
offset
number

The offset to start listing conversations from.

limit
number

The maximum number of conversations to return.

Get Conversation

Fetch a specific conversation by its UUID:

1const conversationId = '123e4567-e89b-12d3-a456-426614174000';
2const conversation = await client.getConversation(conversationId);
conversationId
stringRequired

The UUID of the conversation to retrieve.

Create Conversation

Create a new conversation:

1const newConversation = await client.createConversation();

Add Message

Add a message to an existing conversation:

1const conversationId = '123e4567-e89b-12d3-a456-426614174000';
2const message = { text: 'Hello, world!' };
3const parentId = '98765432-e21b-12d3-a456-426614174000';
4const metadata = { key: 'value' };
5
6const addMessageResponse = await client.addMessage(conversationId, message, parentId, metadata);
conversationId
stringRequired

The UUID of the conversation to add the message to.

message
objectRequired

The message object to add to the conversation.

parentId
string

An optional UUID of the parent message.

metadata
object

An optional metadata object for the message.

Update Message

Update an existing message in a conversation:

1const messageId = '98765432-e21b-12d3-a456-426614174000';
2const updatedMessage = { text: 'Updated message content' };
3
4const updateMessageResponse = await client.updateMessage(messageId, updatedMessage);
messageId
stringRequired

The UUID of the message to update.

message
objectRequired

The updated message object.

Get Branches Overview

Retrieve an overview of branches in a conversation:

1const conversationId = '123e4567-e89b-12d3-a456-426614174000';
2const branchesOverview = await client.branchesOverview(conversationId);
conversationId
stringRequired

The UUID of the conversation to get branches for.

Update Message Metadata

Update the metadata of a message by its ID:

1const messageId = '123e4567-e89b-12d3-a456-426614174000';
2const metadata = {
3 key1: 'value1',
4 key2: 'value2'
5};
6const updateResponse = await client.updateMessageMetadata(messageId, metadata);
messageId
stringRequired

The ID of the message to update.

metadata
objectRequired

The metadata to update.

Delete Conversation

Delete a conversation by its UUID:

1const conversationId = '123e4567-e89b-12d3-a456-426614174000';
2const deleteResponse = await client.deleteConversation(conversationId);
conversationId
stringRequired

The UUID of the conversation to delete.