Skip to main content

Overview

The Config node (Load Config File / Select Config File) loads JSON configuration files into the workflow context. This allows you to separate configuration from workflow logic, manage environment-specific settings, and reuse configuration across multiple workflows.

Node Types

Load Config File

Load JSON configuration from the filesystem.

Select Config File

Load JSON configuration from embedded file content (typically selected through UI).
Both node types have similar functionality and merged implementations. The main difference is the source of the configuration data.

Configuration

Legacy Format (Single File)

filePath
string
Path to the JSON configuration file (for Load Config File node).
  • Relative paths are resolved from project root
  • Absolute paths are supported
  • Supports variable interpolation: config/${data.environment}.json
fileContent
string
JSON configuration content (for Select Config File node).
contextKey
string
Optional context key to store the configuration. If not specified, configuration is merged into root context.

New Format (Multiple Files)

configs
array
Array of configuration file definitions.Config structure:
  • fileName: Display name for the config file
  • fileContent: JSON configuration content
  • enabled: Boolean flag to enable/disable this config
  • contextKey: Optional key to store this config

Examples

Basic Configuration

{
  "type": "loadConfigFile",
  "data": {
    "filePath": "config/settings.json"
  }
}

Multiple Configurations

Load Multiple Files
{
  "type": "loadConfigFile",
  "data": {
    "configs": [
      {
        "fileName": "api-config.json",
        "fileContent": "{\"apiUrl\": \"https://api.example.com\", \"apiKey\": \"key123\"}",
        "enabled": true,
        "contextKey": "apiConfig"
      },
      {
        "fileName": "ui-config.json",
        "fileContent": "{\"theme\": \"dark\", \"language\": \"en\"}",
        "enabled": true,
        "contextKey": "uiConfig"
      },
      {
        "fileName": "debug-config.json",
        "fileContent": "{\"verbose\": true, \"logLevel\": \"debug\"}",
        "enabled": false
      }
    ]
  }
}

Environment-Specific Config

{
  "type": "loadConfigFile",
  "data": {
    "filePath": "config/${data.environment}.json"
  }
}
// Loads: config/production.json, config/staging.json, etc.

API Configuration

API Settings
// config/api.json
{
  "baseUrl": "https://api.example.com",
  "endpoints": {
    "users": "/api/v1/users",
    "products": "/api/v1/products",
    "orders": "/api/v1/orders"
  },
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  "timeout": 30000,
  "retryCount": 3
}

Credentials Configuration

API Keys
// config/credentials.json
{
  "apiKey": "your-api-key-here",
  "apiSecret": "your-api-secret-here",
  "webhookUrl": "https://webhook.example.com",
  "email": {
    "smtpHost": "smtp.example.com",
    "smtpPort": 587,
    "username": "[email protected]",
    "password": "password"
  }
}
Never commit credentials or API keys to version control. Use environment variables or secure secret management systems.

Test Data Configuration

Test Users
// config/test-data.json
{
  "users": [
    {
      "username": "testuser1",
      "email": "[email protected]",
      "password": "Test123!"
    },
    {
      "username": "testuser2",
      "email": "[email protected]",
      "password": "Test456!"
    }
  ],
  "products": [
    { "id": "PROD001", "name": "Widget", "price": 29.99 },
    { "id": "PROD002", "name": "Gadget", "price": 49.99 }
  ]
}

Accessing Configuration Data

// Config merged into root context
const apiUrl = context.getData('apiUrl');
const timeout = context.getData('timeout');
const users = context.getData('users');

Configuration Merging

When loading multiple configs without context keys, they merge into root context. Later configs override earlier ones for duplicate keys:
Load Order
[
  {
    "type": "loadConfigFile",
    "data": {
      "configs": [
        {
          "fileContent": "{\"apiUrl\": \"http://dev.com\", \"debug\": true}",
          "enabled": true
        },
        {
          "fileContent": "{\"apiUrl\": \"http://prod.com\"}",
          "enabled": true
        }
      ]
    }
  }
]
// Result: { apiUrl: "http://prod.com", debug: true }

Common Patterns

Environment Setup

[
  {
    "type": "loadConfigFile",
    "data": {
      "filePath": "config/${data.env}.json"
    }
  },
  {
    "type": "apiRequest",
    "data": {
      "url": "${data.apiUrl}/login",
      "method": "POST",
      "body": "{\"username\": \"${data.username}\", \"password\": \"${data.password}\"}"
    }
  }
]

Multi-Environment Testing

[
  {
    "type": "loadConfigFile",
    "data": {
      "configs": [
        {
          "fileName": "base.json",
          "fileContent": "{\"timeout\": 30000, \"retries\": 3}",
          "enabled": true
        },
        {
          "fileName": "staging.json",
          "fileContent": "{\"apiUrl\": \"https://staging.example.com\"}",
          "enabled": true
        }
      ]
    }
  }
]

Conditional Config Loading

// Use JavaScript Code to determine which config to load
const environment = process.env.NODE_ENV || 'development';
context.setData('environment', environment);

// Then load config with variable

Configuration Validation

Validate in JavaScript Code
const config = context.getData('apiConfig');

if (!config) {
  throw new Error('API configuration not loaded');
}

if (!config.apiUrl) {
  throw new Error('API URL not configured');
}

if (!config.apiKey) {
  throw new Error('API key not configured');
}

console.log('Configuration validated successfully');

File Formats

Valid JSON

{
  "stringValue": "text",
  "numberValue": 42,
  "booleanValue": true,
  "arrayValue": [1, 2, 3],
  "objectValue": {
    "nested": "value"
  },
  "nullValue": null
}

Invalid (Not an Object)

// Invalid - array at root
[1, 2, 3]

// Invalid - primitive at root
"just a string"

// Invalid - number at root
42
Configuration files must contain a JSON object at the root level. Arrays and primitives at the root are not supported.

Notes

Relative file paths are resolved from the project root directory, not from the workflow file location.
When multiple configs are loaded without context keys, they merge into the root context with later configs overriding earlier ones.
Configuration files must be valid JSON. Parsing errors will cause the node to fail unless proper error handling is implemented.

Best Practices

// api-config.json - API settings
// ui-config.json - UI settings  
// test-data.json - Test data
// Load separately with context keys

Build docs developers (and LLMs) love