Skip to content

examples n8n integration#229

Open
PredictiveManish wants to merge 5 commits into
usemoss:mainfrom
PredictiveManish:n8n-integration
Open

examples n8n integration#229
PredictiveManish wants to merge 5 commits into
usemoss:mainfrom
PredictiveManish:n8n-integration

Conversation

@PredictiveManish

@PredictiveManish PredictiveManish commented May 11, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Please ensure that your PR meets the following requirements:

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable).
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Description

  1. moss-n8n-helper.ts - A TypeScript wrapper around the Moss SDK optimized for N8N usage
  2. n8n-moss-workflow.json - An example N8N workflow demonstrating all four core operations
  3. README.md - Comprehensive usage instructions

Fixes #198

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts Outdated
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new cookbook example for integrating Moss with n8n, including a helper wrapper, an importable workflow JSON, and documentation to cover the four core operations requested in #198.

Changes:

  • Added MossN8NHelper TypeScript wrapper around the Moss JS SDK for n8n-style usage.
  • Added an example n8n-moss-workflow.json demonstrating create/add/query/delete flow.
  • Added a cookbook README and a helper test file.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
examples/cookbook/n8n-integration/moss-n8n-helper.ts Introduces the n8n-oriented wrapper API around MossClient.
examples/cookbook/n8n-integration/n8n-moss-workflow.json Provides a sample workflow JSON users can import into n8n.
examples/cookbook/n8n-integration/README.md Documents setup/usage patterns for the helper and workflow.
examples/cookbook/n8n-integration/test_moss_n8n_helper.ts Adds unit tests for the helper (currently written for Jest).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/cookbook/n8n-integration/README.md Outdated
Comment thread examples/cookbook/n8n-integration/README.md
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts Outdated
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts Outdated
Comment thread examples/cookbook/n8n-integration/moss-n8n-helper.ts Outdated
Comment thread examples/cookbook/n8n-integration/test_moss_n8n_helper.ts
Comment thread examples/cookbook/n8n-integration/test_moss_n8n_helper.ts
Comment thread examples/cookbook/n8n-integration/n8n-moss-workflow.json Outdated
Comment thread examples/cookbook/n8n-integration/n8n-moss-workflow.json
Comment thread examples/cookbook/n8n-integration/README.md
@yatharthk2

Copy link
Copy Markdown
Contributor

can you please add .env.example and short demo video ? does not have to be longer than 1 min

PredictiveManish and others added 3 commits May 12, 2026 04:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@CoderOMaster

Copy link
Copy Markdown
Contributor

@PredictiveManish please share the video demo for the n8n integration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

@@ -0,0 +1,262 @@
import { MossClient } from '@moss-dev/moss';
Comment on lines +44 to +47
options?: {
modelId?: string;
onProgress?: (jobProgress: { status: string; progress: number; currentPhase?: string }) => void;
}
Comment on lines +91 to +94
options?: {
upsert?: boolean;
onProgress?: (jobProgress: { status: string; progress: number; currentPhase?: string }) => void;
}
Comment on lines +136 to +138
options?: {
onProgress?: (jobProgress: { status: string; progress: number; currentPhase?: string }) => void;
}
Comment on lines +66 to +68
// If there's a progress callback, we need to poll for status updates
// But for simplicity in this helper, we'll just return the basic result
// Users can call getJobStatus separately if they need progress tracking
Comment on lines +177 to +179
const results = await this.client.query(indexName, queryText, {
topK: options?.topK ?? 10
});
Comment on lines +1 to +5
import { MossN8NHelper } from './moss-n8n-helper';

// Mock MossClient for testing
const mockCreateIndex = jest.fn();
const mockAddDocs = jest.fn();
Comment on lines +238 to +243
describe('close', () => {
it('should call MossClient.close', () => {
helper.close();
expect(mockClose).toHaveBeenCalled();
});
});
Comment on lines +121 to +127
## Demo

See `DEMO_SCRIPT.md` for a script to create a 1-minute demonstration video showing the integration in action.

## License

BSD-2-Clause - See [LICENSE](../LICENSE) for details. No newline at end of file
Comment on lines +36 to +42
{
"parameters": {
"functionCode": "// Example: Create a new index with sample documents\n// In a real workflow, this data would come from previous nodes\n\nconst { projectId, projectKey } = items[0].json;\n\n// This is where you'd use the Moss N8N Helper\n// Since we can't directly import TypeScript in n8n Function nodes,\n// we'll show the logic that would be implemented\n\nconst sampleDocs = [\n { id: 'doc1', text: 'Machine learning is a subset of AI', metadata: { category: 'tech' } },\n { id: 'doc2', text: 'Deep learning uses neural networks with multiple layers', metadata: { category: 'tech' } },\n { id: 'doc3', text: 'Natural language processing enables computers to understand text', metadata: { category: 'tech' } }\n];\n\n// In practice, you would:\n// 1. Create a helper instance: const helper = new MossN8NHelper(projectId, projectKey);\n// 2. Create index: const createResult = await helper.createIndex('knowledge-base', sampleDocs);\n// 3. Wait for completion using getJobStatus in a loop\n// 4. Return the job ID for tracking\n\nreturn [{\n indexName: 'knowledge-base',\n documentCount: sampleDocs.length,\n status: 'index_creation_started',\n note: 'In actual n8n workflow, use Function items to call Moss N8N Helper methods'\n}];"
},
"name": "Create Moss Index",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Integration with N8N

4 participants