Overview
The User class represents a user in your RecallrAI project. It provides methods for managing sessions, memories, messages, and merge conflicts.
Properties
Unique identifier for the user.
User metadata as an object.
UTC timestamp when the user was created.
UTC timestamp of the user’s last activity.
User Management Methods
update()
import { UserAlreadyExistsError } from "recallrai";
try {
const user = await client.getUser("user123");
await user.update({
newMetadata: { name: "John Doe", role: "admin" },
newUserId: "john_doe",
});
console.log(`Updated user ID: ${user.userId}`);
} catch (error) {
if (error instanceof UserAlreadyExistsError) {
console.log(`New user ID already exists: ${error.message}`);
}
}
New metadata to replace the existing metadata.
Optional new user ID. Must be unique within your project.
Returns: void
Raises: UserNotFoundError, UserAlreadyExistsError
refresh()
const user = await client.getUser("john_doe");
await user.refresh();
console.log(`Latest metadata:`, user.metadata);
Returns: void
Raises: UserNotFoundError
delete()
const user = await client.getUser("john_doe");
await user.delete();
This permanently deletes the user and all associated sessions, memories, and messages.
Returns: void
Raises: UserNotFoundError
Session Management Methods
createSession()
const user = await client.getUser("user123");
const session = await user.createSession({
autoProcessAfterSeconds: 600,
metadata: { type: "chat", channel: "web" },
});
console.log(`Created session: ${session.sessionId}`);
Seconds of inactivity before auto-processing. Default: 600.
Optional metadata for the session.