Skip to main content

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 the INodeType 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 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
Example: Discord v2 node (nodes/Discord/v2/DiscordV2.node.ts)
export class DiscordV2 implements INodeType {
  description: INodeTypeDescription;

  methods = {
    listSearch,
    loadOptions,
  };

  async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
    return await router.call(this);
  }
}

INodeType Interface

Every node must implement the INodeType interface with these core components:
ComponentRequiredPurpose
descriptionYesNode metadata and UI configuration
execute()For programmatic nodesCustom execution logic
poll()For polling triggersPeriodic data fetching
trigger()For generic triggersLong-running event listeners
webhook()For webhook triggersHandle incoming webhooks
webhookMethodsFor webhook triggersWebhook lifecycle management
methodsOptionalloadOptions, listSearch, credentialTest, resourceMapping

Development Workflow

1

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
2

Create Node Structure

mkdir packages/nodes-base/nodes/YourService
cd packages/nodes-base/nodes/YourService
touch YourService.node.ts
# Add icon SVG files
3

Implement INodeType

Create the node class with proper description and execution logic.See the Node Structure page for details.
4

Create Credentials

Define credentials in packages/nodes-base/credentials/See the Credentials page for details.
5

Write Tests

Create unit tests following testing guidelines.See the Testing page for details.
6

Build and Test

cd packages/nodes-base
pnpm build
pnpm test YourService

Node Parameters

Nodes define their UI through parameters in the description.properties array. Common parameter types:
{
  displayName: 'Message',
  name: 'message',
  type: 'string',
  default: '',
  placeholder: 'Enter your message',
  description: 'The message to send'
}

Conditional UI with displayOptions

Use displayOptions to show/hide parameters based on other parameter values:
{
  displayName: 'User ID',
  name: 'userId',
  type: 'string',
  displayOptions: {
    show: {
      resource: ['user'],
      operation: ['get', 'update', 'delete'],
    },
  },
  default: '',
}
Use noDataExpression: true for resource and operation selectors to prevent expression evaluation in the UI.

Best Practices

TypeScript

  • Never use any type - use proper types or unknown
  • Avoid type casting with as - use type guards instead
  • Define interfaces for API responses

Error Handling

  • Use NodeOperationError for user-facing errors
  • Use NodeApiError for API-related errors
  • Support continueOnFail option 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 displayName and description fields
  • Set sensible default values
  • Use displayOptions to show/hide fields conditionally
  • Add helpful hints and builder hints for AI agents

Example Nodes Reference

Node TypeExample NodeSource
ProgrammaticDiscord v2nodes/Discord/v2/DiscordV2.node.ts
DeclarativeOktanodes/Okta/Okta.node.ts
Webhook TriggerMicrosoft Teamsnodes/Microsoft/Teams/MicrosoftTeamsTrigger.node.ts
Polling TriggerGmail Triggernodes/Google/Gmail/GmailTrigger.node.ts
Generic TriggerMQTTnodes/MQTT/MqttTrigger.node.ts
VersionedSetnodes/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
Always build the nodes-base package after making changes:
cd packages/nodes-base
pnpm build > build.log 2>&1
tail -n 20 build.log