This guide provides tips for effectively using Memobase in your applications.
You can define the structure of user profiles by configuring topics and sub-topics in your config.yaml
file. This tells Memobase what kind of information to track.
Memobase uses this configuration to generate structured user profiles. Learn more about customization at Profile Configuration.
There are two primary ways to retrieve and use a user’s memory.
The Profile API returns a structured JSON object containing the user’s profile data. You are responsible for formatting this JSON into a string and inserting it into your prompt.
Key Considerations:
max_token_size
to set a hard limit and max_subtopic_size
to limit the number of sub-topics per topic.only_topics
to retrieve specific profile sections or prefer_topics
to prioritize the most important information.The Context API returns a pre-formatted string containing both the user’s profile and recent events, ready to be injected directly into your system prompt. It uses a template like this:
Memobase uses a buffer to collect user interactions. A flush
operation processes this buffer and updates the long-term memory. Flushing occurs automatically when:
You can also trigger it manually with the flush
API. It is best practice to call flush
at the end of a user session or conversation.
A single user in your application can correspond to multiple Memobase users. This is useful for creating segmented memories.
We recommend designing your system with a one-to-many mapping between your application’s user ID and Memobase user IDs.
You can add metadata to the messages you insert to provide more context for memory extraction.
alias
to specify the name of the AI assistant in the conversation.
created_at
timestamp for each message so Memobase can build a timeline of events.
See a full implementation in our demo script.