Can n8n custom nodes have a primary node with multiple action nodes nested inside?

I’m working on an n8n custom node for my company. Right now, when I look for it in the node panel, I see two separate action nodes (authenticate and upload file). But this isn’t what I want.

I’m trying to create a structure like the S3 node, where there’s one main node with a dropdown to pick different actions. I don’t want separate core nodes for each action.

I’ve set up my main.node.ts file with authentication and file upload operations. In my package.json, I’ve listed both action nodes under the ‘main’ key. But this approach isn’t giving me the nested structure I’m after.

I also tried making separate auth.node.ts and upload.node.ts files and adding them to package.json. But that just created two standalone nodes.

Any ideas on how to get that main node with nested actions setup? I’m stumped and could use some guidance.

Having developed custom nodes for n8n, I can offer some insight into your situation. The structure you’re aiming for is indeed possible, but it requires a specific approach in your node’s configuration.

The key is to define a ‘Resource’ or ‘Operation’ field in your node’s properties. This field will act as your dropdown menu. In your execute method, you’ll then use a switch statement to handle different actions based on the selected option.

Your main.node.ts file should contain all the logic for different operations. You’ll need to adjust your displayOptions to show/hide fields based on the selected action.

This approach consolidates everything into a single node, providing the nested structure you’re after. It takes some refactoring, but it’s worth it for a cleaner, more intuitive user experience.

Remember to thoroughly test each action to ensure smooth functionality across all operations.

hey gizmo, been there done that! ur on the right track with the S3 setup. key is using a single main.node.ts file and setting up a resource/operation field as ur dropdown. then use a switch statement in ur execute method to handle diff actions. it’s a bit tricky but totally doable. good luck!

As someone who’s been deep in the n8n custom node development trenches, I can relate to your struggle. I faced a similar challenge when building a complex node for our team.

The key to achieving that S3-like structure lies in how you configure your description object within your main node file. You’ll want to define an options array that includes all your actions as separate objects. Each action object should have properties like name, value, and description.

Then, in your execute function, use a switch statement based on the selected option to determine which action to perform. This approach allows you to have a single node with multiple actions accessible via a dropdown.

Remember to properly handle the UI changes for each action in your loadOptions function. It took me a bit of trial and error, but once I got it working, it made our custom node much more user-friendly and maintainable.

Hope this helps point you in the right direction!