examples n8n integration#229
Open
PredictiveManish wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
MossN8NHelperTypeScript wrapper around the Moss JS SDK for n8n-style usage. - Added an example
n8n-moss-workflow.jsondemonstrating 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.
Contributor
|
can you please add .env.example and short demo video ? does not have to be longer than 1 min |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…/moss into n8n-integration
Contributor
|
@PredictiveManish please share the video demo for the n8n integration. |
| @@ -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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please ensure that your PR meets the following requirements:
Description
moss-n8n-helper.ts- A TypeScript wrapper around the Moss SDK optimized for N8N usagen8n-moss-workflow.json- An example N8N workflow demonstrating all four core operationsREADME.md- Comprehensive usage instructionsFixes #198
Type of Change