I’m working on building a custom n8n node for my service (let’s call it MyService). I want users to find one main node when they search, but then be able to choose different operations from a dropdown menu inside that node.
Right now I have two separate operations: login and document upload. When I search for MyService in the node panel, I can see both operations, but I want them grouped under one main node like how AWS S3 node works.
I don’t want two separate core nodes (like MyService Login and MyService Document Upload). Instead I want one MyService node with an operation selector.
Here’s my current setup:
package.json configuration:
"nodes": {
"main": [
"dist/nodes/main/login.node.js",
"dist/nodes/main/documentUpload.node.js"
]
}
Main node implementation:
export class MyService implements INodeType {
description: INodeTypeDescription = {
displayName: 'MyService',
name: 'MyService',
icon: 'file:MyService.png',
group: ['transform'],
version: 1,
description: 'Handle authentication and file processing operations.',
defaults: {
name: 'MyService',
color: '#2E8B57',
},
inputs: ['main'],
outputs: ['main'],
properties: [
{
displayName: 'Action',
name: 'action',
type: 'options',
options: [
{
displayName: 'Login',
name: 'Login',
value: 'Login',
description: 'Authenticate with your credentials',
},
{
displayName: 'Document Upload',
name: 'documentUpload',
value: 'documentUpload',
description: 'Upload and process a document',
},
],
default: 'Login',
description: 'Choose the action to perform',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
default: '',
displayOptions: {
show: {
action: ['Login'],
},
},
description: 'Your account email address',
required: true,
},
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: {
password: true,
},
displayOptions: {
show: {
action: ['Login'],
},
},
default: '',
description: 'Your API key for authentication',
required: true,
},
{
displayName: 'Workspace ID',
name: 'workspaceId',
type: 'string',
displayOptions: {
show: {
action: ['documentUpload'],
},
},
default: '',
description: 'ID of the target workspace.',
},
{
displayName: 'Document Type',
name: 'documentType',
type: 'string',
displayOptions: {
show: {
action: ['documentUpload'],
},
},
default: '',
description: 'Type of document being uploaded.',
},
{
displayName: 'Document Data',
name: 'documentData',
type: 'string',
displayOptions: {
show: {
action: ['documentUpload'],
},
},
default: '',
placeholder: 'Choose document...',
typeOptions: {
multipleValues: false,
multipleValueButtonText: 'Add Document',
},
required: true,
description: 'The document file to upload.',
},
],
};
}
I tried making separate login.node.ts and upload.node.ts files and adding them to package.json, but that just creates two individual core nodes which isn’t what I want.
What’s the correct way to structure this so I get one unified node with operation selection?