Skip to main content

Interface AddMemoryOptions

These options allow you to categorize and add rich context to a memory entry. This metadata is crucial for later filtering and semantic retrieval.
PropertyTypeDescription
producerstringOptional. The Entity ID of who created the memory.
produced_forstringOptional. The Target Entity ID the memory is intended for.
roleMemoryProducerRoleOptional. The role of the creator (user, assistant, or system).
episode_typestringOptional. A custom category for the entry (e.g., 'conversation', 'note').
metadataRecord<string, unknown>Optional. A key-value map for any additional custom data.
typesMemoryType[]Optional. Specify if this should be stored as episodic, semantic, or both.

Interface AddMemoryResult

This is the confirmation object returned by the server after successfully adding a memory.
PropertyTypeDescription
resultsobject[]An array of objects, each containing a uid (string) for the newly created entry.

Usage Example

import { MemMachineClient } from '@memmachine/client';

const memory = client.project({ org_id: 'org_1', project_id: 'proj_1' }).memory();

// Adding a memory with full context
const response = await memory.add("The user prefers dark mode for the UI.", {
  producer: "user_123",
  role: "user",
  episode_type: "preference",
  metadata: {
    platform: "mobile",
    timestamp: Date.now()
  }
});

// Accessing the new memory ID
const newId = response.results[0].uid;
console.log(`Memory stored with ID: ${newId}`);