Redis Chat Memory
Redis Chat Memory is a simple tool that lets you keep a record of chat messages in a Redis database. It’s useful when you want a chatbot or any conversational AI to remember what was said earlier in the same conversation.
How it Works
When you add this component to a workflow, it connects to a Redis server using the connection string you set in a Redis API credential.
Each conversation is identified by a Session ID that you provide.
The component stores every message in Redis under that session ID and can later retrieve the whole conversation history. This makes it easy for your AI to “remember” previous messages without having to keep everything in memory.
Inputs
This component requires a Redis API credential.
- First, create a Redis API credential in Nappai’s credentials section.
- Then, select that credential in the component’s Credential field.
Input Fields
- Session ID: A unique identifier for the conversation. Use a different ID for each user or chat session so that messages don’t get mixed up.
Outputs
- Memory: A
BaseChatMessageHistory
object that contains all the messages for the specified session. You can feed this output into other components that need the conversation history.
Usage Example
- Create a Redis API credential with your Redis server’s connection string.
- Add the Redis Chat Memory component to your workflow.
- Set the Session ID (e.g.,
user_12345
). - Select the credential you created in step 1.
- Connect the component’s Memory output to a chatbot or LLM component that can read the conversation history.
- When the user sends a new message, the chatbot can read the stored history, generate a response, and the component will automatically update the history in Redis.
Related Components
- Chat Memory – A generic memory component that can store chat history in memory.
- Redis Connection – A component that establishes a raw connection to Redis for custom queries.
- LLM Chat – Uses the conversation history to generate responses.
Tips and Best Practices
- Use a unique Session ID for each user or chat thread to avoid data overlap.
- Keep your Redis credentials secure; never expose the connection string in public workflows.
- If you need to clear a conversation, delete the session key in Redis or use a separate component to purge it.
Security Considerations
- The Redis connection string contains the password, so store it in a protected credential.
- Ensure that only authorized users can access the component and the underlying Redis database.
- Regularly rotate your Redis credentials to reduce the risk of unauthorized access.