Node Development Overview
n8n’s extensibility comes from its node-based architecture. Each node is a self-contained unit that performs a specific task in a workflow. This guide will help you understand how to create custom nodes to integrate with any service or API.What is a Node?
A node is a TypeScript class that implements theINodeType interface. Nodes can:
- Execute operations - Perform API calls, data transformations, or custom logic
- Trigger workflows - Start workflows based on webhooks, polling, or events
- Process data - Transform, filter, or enrich data flowing through workflows
- Integrate services - Connect to external APIs and platforms
Node Types
n8n supports three main types of nodes:- Programmatic Nodes
- Declarative Nodes
- Trigger Nodes
Programmatic nodes use custom TypeScript code in an
execute() function to perform operations.Use cases:- Complex data transformations
- Custom business logic
- Operations requiring conditional processing
- Multiple API endpoints with custom routing
nodes/Discord/v2/DiscordV2.node.ts)INodeType Interface
Every node must implement theINodeType interface with these core components:
| Component | Required | Purpose |
|---|---|---|
description | Yes | Node metadata and UI configuration |
execute() | For programmatic nodes | Custom execution logic |
poll() | For polling triggers | Periodic data fetching |
trigger() | For generic triggers | Long-running event listeners |
webhook() | For webhook triggers | Handle incoming webhooks |
webhookMethods | For webhook triggers | Webhook lifecycle management |
methods | Optional | loadOptions, listSearch, credentialTest, resourceMapping |
Development Workflow
Plan Your Node
Determine:
- Node type (programmatic, declarative, or trigger)
- Operations to support (create, read, update, delete, etc.)
- Required credentials and authentication method
- Parameters users need to configure
Implement INodeType
Create the node class with proper description and execution logic.See the Node Structure page for details.
Create Credentials
Define credentials in
packages/nodes-base/credentials/See the Credentials page for details.Write Tests
Create unit tests following testing guidelines.See the Testing page for details.
Node Parameters
Nodes define their UI through parameters in thedescription.properties array. Common parameter types:
Conditional UI with displayOptions
UsedisplayOptions to show/hide parameters based on other parameter values:
Use
noDataExpression: true for resource and operation selectors to prevent expression evaluation in the UI.Best Practices
TypeScript
- Never use
anytype - use proper types orunknown - Avoid type casting with
as- use type guards instead - Define interfaces for API responses
Error Handling
- Use
NodeOperationErrorfor user-facing errors - Use
NodeApiErrorfor API-related errors - Support
continueOnFailoption when appropriate
Code Organization
- Separate operation/field descriptions into separate files
- Create reusable API request helpers in GenericFunctions
- Use kebab-case for files, PascalCase for classes
UI/UX
- Use clear
displayNameanddescriptionfields - Set sensible default values
- Use
displayOptionsto show/hide fields conditionally - Add helpful hints and builder hints for AI agents
Example Nodes Reference
| Node Type | Example Node | Source |
|---|---|---|
| Programmatic | Discord v2 | nodes/Discord/v2/DiscordV2.node.ts |
| Declarative | Okta | nodes/Okta/Okta.node.ts |
| Webhook Trigger | Microsoft Teams | nodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts |
| Polling Trigger | Gmail Trigger | nodes/Google/Gmail/GmailTrigger.node.ts |
| Generic Trigger | MQTT | nodes/MQTT/MqttTrigger.node.ts |
| Versioned | Set | nodes/Set/Set.node.ts |
Next Steps
Node Structure
Learn about INodeType interface and node architecture
Credentials
Implement authentication and credential management
Testing
Write comprehensive tests for your nodes
Versioning
Manage node versions and breaking changes