UNPKG

n8n-nodes-zep-v3

Version:

Community node: Zep Memory (v3) - AI Agent Memory for n8n

402 lines (317 loc) โ€ข 11.6 kB
# n8n-nodes-zep-v3 [![npm version](https://badge.fury.io/js/n8n-nodes-zep-v3.svg)](https://www.npmjs.com/package/n8n-nodes-zep-v3) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) Community node package that **replicates 100%** of the deprecated Zep nodes using **Zep API v3 semantics** (threads & user context) while preserving the **same UX** in n8n. > ๐Ÿ”„ **Drop-in replacement** for the deprecated `@n8n/n8n-nodes-langchain.memoryZep` that stopped working with Zep Cloud. ## โœจ Features - **๐Ÿง  Zep Memory (v3)** โ€” Sub-node that plugs into AI Agent/Chat nodes via the `ai_memory` port - **โ˜๏ธ Zep Cloud compatible** โ€” Works seamlessly with https://api.getzep.com - **๐Ÿ”„ Sessions โ†’ Threads mapping** โ€” Automatic conversion for v2 compatibility - **๐Ÿš€ Auto-thread creation** โ€” Creates threads automatically when needed - **๐Ÿ“Š User context support** โ€” Advanced context retrieval (basic/summary modes) - **๐Ÿ” API Response validation** โ€” Robust error handling and data validation - **๐Ÿ› Debug logging** โ€” Comprehensive logs for troubleshooting ## ๐ŸŽฏ Why This Package? The original n8n Zep nodes stopped working when Zep migrated from v2 to v3 API: - โŒ `@n8n/n8n-nodes-langchain.memoryZep` throws "resource not found" errors - โŒ Incompatible with Zep Cloud (uses v3 API) - โŒ Community workflows broken for months This package solves these issues: - โœ… **Same interface** โ€” No workflow changes needed - โœ… **Zep v3 API** โ€” Compatible with latest Zep Cloud - โœ… **Enhanced features** โ€” Additional context modes and auto-creation ## ๐Ÿ“‹ Requirements - **n8n**: >= 1.82.0 - **Zep**: Cloud account or self-hosted v3 - **Installation**: Self-hosted n8n only (community packages not supported on n8n Cloud) ## ๐Ÿš€ Installation ### Method 1: NPM (Recommended) ```bash # Navigate to your n8n custom nodes directory cd ~/.n8n/custom # Install the package npm install n8n-nodes-zep-v3 # Restart n8n ``` ### Method 2: Git Clone ```bash # Navigate to your n8n custom nodes directory cd ~/.n8n/custom # Clone the repository git clone https://github.com/fabiohsan/n8n-nodes-zep-v3.git # Install dependencies and build cd n8n-nodes-zep-v3 npm install npm run build # Restart n8n ``` ### Docker Installation ```bash # Connect to your n8n container docker exec -it your_n8n_container bash # Navigate to custom directory cd /home/node/.n8n/custom # Install package npm install n8n-nodes-zep-v3 # Exit and restart container exit docker restart your_n8n_container ``` ## โš™๏ธ Configuration ### 1. Set up Zep API v3 Credentials 1. In n8n, go to **Credentials** โ†’ **Add Credential** 2. Search for **"Zep API (v3)"** 3. Configure: - **API Key**: Your Zep API key from [Zep Cloud](https://app.getzep.com) - **Base URL**: `https://api.getzep.com` (default for Zep Cloud) ### 2. Test Connection Click **Test** to verify your credentials work with Zep v3 API. ## ๐Ÿ“– Usage ### Zep Memory (v3) Node The memory node acts as a **sub-node** that connects to AI Agent/Chat nodes via the special `ai_memory` port. #### Basic Setup 1. Add **"Zep Memory (v3)"** node to your workflow 2. Connect it to your **AI Agent** node via the **memory port** 3. Configure the **Session ID** parameter 4. Run your workflow #### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | **Session ID** | string | *required* | Unique identifier for the conversation thread | | **Mode** | options | `basic` | Context retrieval mode (`basic` or `summary`) | | **Auto-create Thread** | boolean | `true` | Automatically create thread if it doesn't exist | | **Return Context on Add** | boolean | `false` | Return context when adding messages | | **User ID** | string | `""` | Optional user ID for cross-thread graph building | #### Example Configuration ```javascript // Session ID examples "user_123_session" // User-specific session "chat_{{ $json.conversation_id }}" // Dynamic from input data "support_ticket_456" // Support conversation ``` ### Zep Vector Store (v3) Node The vector store node provides document storage and semantic search capabilities. #### Operations ##### Insert Documents ```javascript // Input data structure { "content": "Your document content here", "metadata": { "category": "support", "language": "en", "timestamp": "2025-01-01T00:00:00Z" } } ``` ##### Search Documents ```javascript // Search configuration { "query": "How do I reset my password?", "limit": 10, "searchType": "similarity" // or "mmr" } ``` ##### Get Many Documents ```javascript // Retrieve by UUIDs or document IDs { "uuids": "uuid1,uuid2,uuid3", "documentIds": "doc1,doc2,doc3" } ``` ## ๐Ÿ”„ Migration from Legacy Zep Nodes ### Before (Broken) ```json { "nodes": [ { "parameters": {}, "type": "@n8n/n8n-nodes-langchain.memoryZep", "credentials": { "zepApi": "your_old_credentials" } } ] } ``` ### After (Working) ```json { "nodes": [ { "parameters": { "sessionId": "{{ $json.user_id }}" }, "type": "zepMemoryV3", "credentials": { "zepApiV3": "your_new_credentials" } } ] } ``` ### Migration Steps 1. โœ… Install `n8n-nodes-zep-v3` 2. โœ… Create new **Zep API (v3)** credentials 3. โœ… Replace old **Zep Memory** nodes with **Zep Memory (v3)** 4. โœ… Update node parameters (add explicit `sessionId`) 5. โœ… Test your workflows ## ๐ŸŽญ Example Workflows ### Basic AI Chatbot with Memory ```javascript [Manual Trigger] โ†“ [Zep Memory (v3)] โ†’ [AI Agent (OpenAI)] โ†“ โ†“ [Return Response] โ† [Format Output] ``` ### Customer Support with Vector Search ```javascript [Webhook Trigger] โ†“ [Zep Vector Store (v3) - Search] โ†’ [AI Agent with Context] โ†“ โ†“ [Zep Memory (v3)] โ† [Format Support Response] ``` ### Document Ingestion Pipeline ```javascript [Schedule Trigger] โ†“ [Read Files] โ†’ [Zep Vector Store (v3) - Insert] โ†“ โ†“ [Process Text] [Confirm Upload] ``` ## ๐Ÿ› ๏ธ API Compatibility ### Zep v2 โ†’ v3 Mapping | Zep v2 Concept | Zep v3 Equivalent | This Package | |----------------|-------------------|--------------| | `sessions` | `threads` | โœ… Auto-mapped | | `memory.get` | `thread.get_user_context` | โœ… Supported | | `memory.add` | `thread.add_messages` | โœ… Supported | | `memory.delete` | `thread.delete` | โœ… Supported | | Collections | Collections | โœ… Unchanged | ### API Endpoints Used - `GET /api/v2/threads/{id}/messages` - Retrieve conversation history - `POST /api/v2/threads/{id}/messages` - Add new messages - `GET /api/v2/threads/{id}/context` - Get user context - `DELETE /api/v2/threads/{id}` - Clear thread - `POST /api/v2/collections/{name}/search` - Vector search - `POST /api/v2/collections/{name}/documents` - Insert documents ## ๐Ÿ”ง Troubleshooting ### Common Issues #### "Couldn't connect with these settings" - โœ… Check API key is correct - โœ… Verify Base URL is `https://api.getzep.com` (not `app.getzep.com`) - โœ… Ensure you have Zep Cloud access #### "Thread not found" - โœ… Enable **Auto-create Thread** option - โœ… Check Session ID is not empty - โœ… Verify thread exists in Zep Cloud dashboard #### "Node not appearing in n8n" - โœ… Restart n8n after installation - โœ… Check package installed in correct directory - โœ… Verify n8n version >= 1.82 #### Memory not persisting - โœ… Ensure Session ID is consistent across workflow runs - โœ… Check Zep Memory node is connected to AI Agent memory port - โœ… Verify credentials are valid ### Debug Mode Enable verbose logging by setting: ```bash export N8N_LOG_LEVEL=debug ``` ### Getting Help 1. ๐Ÿ› **GitHub Issues**: [Report bugs](https://github.com/fabiohsan/n8n-nodes-zep-v3/issues) 2. ๐Ÿ’ฌ **n8n Community**: [Discuss usage](https://community.n8n.io) 3. ๐Ÿ“– **Zep Docs**: [API Reference](https://docs.getzep.com) ## ๐Ÿงช Testing ### Manual Testing ```bash # Run type checking npm run lint # Build package npm run build # Test in development n8n instance npm run watch # for development ``` ### Integration Testing 1. Create test workflow with Zep Memory node 2. Send test messages through AI Agent 3. Verify memory persistence across conversations 4. Test vector search with sample documents ## ๐Ÿค Contributing We welcome contributions! Please: 1. ๐Ÿด Fork the repository 2. ๐ŸŒฟ Create a feature branch 3. โœ… Add tests for new functionality 4. ๐Ÿ“ Update documentation 5. ๐Ÿ”„ Submit a pull request ### Development Setup ```bash git clone https://github.com/fabiohsan/n8n-nodes-zep-v3.git cd n8n-nodes-zep-v3 npm install npm run watch # Development mode ``` ## ๐Ÿ“„ License MIT License - see [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - **n8n Team** - For the amazing workflow automation platform - **Zep Team** - For the powerful memory management service - **Community** - For feedback and feature requests ## ๐Ÿ”— Links - ๐Ÿ“ฆ [NPM Package](https://www.npmjs.com/package/n8n-nodes-zep-v3) - ๐Ÿ’ป [GitHub Repository](https://github.com/fabiohsan/n8n-nodes-zep-v3) - ๐ŸŒ [Zep Cloud](https://app.getzep.com) - ๐Ÿ“š [Zep Documentation](https://docs.getzep.com) - ๐Ÿค– [n8n Documentation](https://docs.n8n.io) --- ## ๐Ÿ“ Changelog ### v0.2.5 (2025-10-02) **๐Ÿ” Authentication Fix** - Added Authorization headers to all HTTP requests - Fixed 401 Unauthorized error when connecting to Zep API - Headers now include: `Authorization: Api-Key {token}` - All methods (loadMemoryVariables, saveContext, clear) now properly authenticated - Thread auto-creation now works correctly with authentication ### v0.2.4 (2025-10-02) **๐Ÿ”ง Major Fix - Langchain Compatibility** - Implemented proper Langchain `BaseChatMemory` interface - Added `loadMemoryVariables()` method (replaces getMessages) - Added `saveContext()` method (replaces addMessages) - Added required properties: `memoryKey`, `returnMessages`, `inputKey`, `outputKey` - Now fully compatible with n8n AI Agent nodes - Fixed message format conversion (role โ†’ type: 'human'/'ai') ### v0.2.3 (2025-10-02) **๐Ÿ› Critical Fix** - Fixed `supplyData` method implementation (was using wrong interface) - Changed from `IExecuteFunctions` to `ISupplyDataFunctions` - Resolved "Node does not have a `supplyData` method defined" error - Now properly works as AI Memory sub-node ### v0.2.2 (2025-10-02) **โœจ UX Improvements** - ๐ŸŽฏ Auto-suggest `{{ $json.sessionId }}` from Chat Trigger for Session ID field - ๐Ÿ’ก Added helpful hints and placeholders for all fields - ๐Ÿ“ Improved field descriptions with examples - ๐Ÿ”— Better integration with Chat Trigger nodes ### v0.2.1 (2025-10-02) **๐Ÿ› Hotfix** - Fixed class name export (ZepMemoryV3 โ†’ ZepMemory) - Resolved "package could not be loaded" error ### v0.2.0 (2025-10-02) **๐ŸŽฏ Improvements & Optimization** - โšก Simplified execute() - removed unnecessary loop for better performance - ๐Ÿ›ก๏ธ Added API response validation to prevent silent failures - ๐Ÿ” Added comprehensive debug logging for troubleshooting - ๐Ÿšซ Removed Zep Vector Store node (focusing on AI Memory only) - โœ… Better error messages and handling - ๐Ÿ“ฆ Cleaner, more maintainable codebase ### v0.1.6 (Previous) - Initial release with Zep v3 API support - Zep Memory sub-node for AI Agents - Auto-thread creation - User context support --- **โญ If this package helped you, please give it a star on GitHub!**