Conversation Chat Memory
The Conversation Chat Memory component lets you keep track of all the messages that belong to a specific conversation. It stores the chat history so that later steps in your workflow can read or update it, making it easier to build conversational AI or automated support flows.
How it Works
When you add this component to a flow, you give it three pieces of information:
- Session ID – a unique identifier for the current user session.
- Conversation ID – a unique identifier for the particular conversation you’re tracking.
- Max Messages – how many past messages you want to keep (default is 10).
The component then creates a message history object that talks to Nappai’s internal storage. It pulls the last Max Messages entries that match the Session ID and Conversation ID, and it can also add new messages to that history. The result is a BaseChatMessageHistory
object that other components can read from or write to.
Because everything happens inside Nappai, no external APIs are called. All data stays within your Nappai environment, so you don’t need to worry about network latency or third‑party service limits.
Inputs
Input Fields
- Conversation ID: The unique ID that identifies the conversation you want to track.
- Max Messages: The maximum number of past messages to keep in the history.
- Session ID: The unique ID that identifies the user session.
Outputs
- Memory: A
BaseChatMessageHistory
object that contains the retrieved chat messages.
This output can be passed to other components that need to read the conversation history or add new messages.
Usage Example
- Add the component to your flow and give it a name like “Chat History”.
- Set the Session ID to the user’s session (you can use a variable from a previous component).
- Set the Conversation ID to the current conversation (again, often a variable).
- Set Max Messages to 20 if you want to keep more history.
- Connect the Memory output to a component that needs the conversation history, such as a language‑model prompt builder or a database writer.
This setup lets your workflow remember what the user said earlier, so the AI can respond in context.
Related Components
- LCChatMemoryComponent – The base class that provides common memory functionality.
- NappaiChatMessageHistory – The underlying storage system that actually saves and retrieves messages.
Tips and Best Practices
- Keep Session ID and Conversation ID unique and consistent; otherwise, you’ll mix up different conversations.
- Use a reasonable Max Messages value to balance memory usage and context length.
- If you need to clear a conversation, delete the history from the Nappai storage or reset the IDs.
Security Considerations
- Treat Session ID and Conversation ID as sensitive data. Store them securely and avoid exposing them in logs or UI.
- Ensure that only authorized users can read or modify the conversation history to protect privacy.