Documentation

Community Node Development

A step-by-step guide on structuring a Community Node for nLink Workflows and the process of publishing it to the NPM registry.

Standard Directory Structure

Using the nlink-community.discord node as an example, a standard project structure includes the following core files:

nlink-community.discord/
├── package.json      # Package configuration, declares the node for nLink
├── definition.json   # UI definition, input and output configuration parameters
├── execution.js      # Core business execution logic (Backend JavaScript)
├── icon.svg          # Vector icon representing the node
└── README.md         # Comprehensive usage instructions

Exploring the Components

  • package.json
    Contains package metadata. Pay special attention to the "nlink" property, which enables the platform to automatically detect nodes located within the directory.
    {
      "name": "nlink-community-discord",
      "version": "1.0.6",
      "description": "Discord Webhook community node",
      "nlink": {
        "nodes": [
          "nlink-community.discord"
        ]
      }
    }
  • definition.json
    Defines the Node's visual structure and User Interface on the Web Canvas. The properties array is the most critical component, determining the input fields requiring user configuration.
    "properties": [
      {
        "displayName": "Channel ID",
        "name": "channelId",
        "type": "string",
        "description": "Enter your Discord channel ID here.",
        "placeholder": "Example: 10123456789",
        "required": true,
        "displayOptions": {
          "show": { "operation": ["sendMessage"] }
        }
      }
    ]
    Standard structure of a Property:
    • displayName: The label displayed on the user interface.
    • name: The variable key used to access values within execution.js (e.g., params.channelId).
    • type: The visual data type (e.g., string, number, boolean, options, json).
    • required: Defines whether this field is mandatory (true/false).
    • displayOptions: Visibility conditions. This helps create a dynamic interface, such as only displaying field B when field A satisfies a specific condition.
  • execution.js
    The JavaScript script executed server-side. The Node JavaScript Runtime provides out-of-the-box state objects, such as credentials and params, along with helpers like http.
    // Construct output data for the Node
    $output = {
      status: "success",
      message_sent: params.content,
      auth_used: credentials.bot_token ? "bot" : "webhook"
    };
  • icon.svg & README.md
    icon.svg: The node's icon, preferably a vector format with square proportions.
    README.md: Community guidelines and documentation, ideally accompanied by screenshots illustrating the node's operation.

Publishing to the NPM Registry

To share your polished node on the nLink Marketplace (which automatically syncs via NPM), you must first register an account on npmjs.com.

# 1. Login to NPM via Terminal
npm login

# 2. Publish your Node!
npm publish --access public

Pro Tip: Every time you modify your Node, you must bump the version number in both package.json and definition.json before republishing.