# n8n-nodes-zep-memory

This is an n8n community node that provides integration with Zep AI Memory Service for managing users, sessions, and conversation memories in AI-powered applications.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### Community Node Installation

1. Go to **Settings** > **Community Nodes**
2. Select **Install a community node**
3. Enter `n8n-nodes-zep-memory` as the npm package name
4. Click **Install**

### Manual Installation (Development)

1. Clone this repository
2. Install dependencies: `npm install`
3. Build the node: `npm run build`
4. Link to your n8n installation: `npm link`
5. In your n8n installation directory: `npm link n8n-nodes-zep-memory`

## Credentials

The node requires **Zep API** credentials:

- **Base URL**: Your Zep Memory Service URL (e.g., `https://your-service.run.app`)
- **API Key**: Your N8N API key for authentication

## Operations

### User Resource

- **Create User**: Create a new user with ID, email, name, and metadata
- **Get User**: Retrieve user information by ID
- **Update User**: Update user details
- **Delete User**: Remove a user
- **List Users**: Get all users

### Session Resource

- **Create Session**: Create a new chat session
- **Get Session**: Retrieve session information
- **Update Session**: Update session metadata
- **Delete Session**: Remove a session
- **List Sessions**: Get all sessions

### Memory Resource

- **Get Memory**: Retrieve conversation history for a session
- **Add Memory**: Add new messages to session memory
- **Delete Memory**: Clear session memory

## Usage Examples

### Creating a User and Session

1. **Create User Node**:
   - Resource: User
   - Operation: Create
   - User ID: `user_123`
   - Email: `user@example.com`
   - First Name: `John`
   - Last Name: `Doe`

2. **Create Session Node**:
   - Resource: Session
   - Operation: Create
   - Session ID: `session_456`
   - User ID: `user_123`
   - Metadata: `{"channel": "web", "bot": "assistant"}`

### Adding Memory

3. **Add Memory Node**:
   - Resource: Memory
   - Operation: Add
   - Session ID: `session_456`
   - Messages: 
   ```json
   [
     {"role": "user", "content": "Hello, how are you?"},
     {"role": "assistant", "content": "I'm doing well, thank you! How can I help you today?"}
   ]
   ```

### Retrieving Memory

4. **Get Memory Node**:
   - Resource: Memory
   - Operation: Get
   - Session ID: `session_456`

## Message Format

Messages should follow this structure:

```json
[
  {
    "role": "user",
    "content": "User message text"
  },
  {
    "role": "assistant", 
    "content": "Assistant response text"
  }
]
```

Supported roles:
- `user`: Messages from the human user
- `assistant`: Messages from the AI assistant
- `system`: System messages (optional)

## Error Handling

The node includes built-in error handling:
- Invalid JSON in message fields will throw an error
- API authentication failures are reported
- Network connectivity issues are handled gracefully
- Use "Continue on Fail" option to handle errors in workflows

## Workflow Integration

This node works well with:
- **HTTP Request** nodes for incoming webhooks
- **OpenAI** nodes for AI responses
- **Code** nodes for message processing
- **IF** nodes for conditional logic
- **Set** nodes for data transformation

## Development

### Building

```bash
npm run build
```

### Linting

```bash
npm run lint
npm run lintfix
```

### Publishing

```bash
npm publish
```

## Support

- Documentation: [Zep AI Memory Service](https://github.com/your-username/zep-memory-service)
- Issues: [GitHub Issues](https://github.com/your-username/n8n-nodes-zep-memory/issues)
- n8n Community: [n8n Community Forum](https://community.n8n.io/)

## License

MIT

## Version History

### 1.0.0
- Initial release
- Support for User, Session, and Memory operations
- Full CRUD operations
- Authentication with API keys