secuencialgenerator

N8N node for auto-incrementing sequential values with mathematical operations (sum, multiply, subtract)

Package Information

Downloads: 0 weekly / 14 monthly
Latest Version: 0.2.1
Author: Steven Checo

Documentation

n8n-nodes-secuencialgenerator

This is an n8n community node that provides an auto-increment generator with persistent state for your n8n workflows.

n8n is a fair-code licensed workflow automation platform.

Features

The SecuencialGenerator node is an auto-incrementing value generator that performs mathematical operations on a sequence value each time it executes. It supports three operation types:

  1. Sum By: Add a value to the current sequence
  2. Multiply By: Multiply the current sequence by a value
  3. Subtract By: Subtract a value from the current sequence

Each execution returns the updated sequence value in the format: { sequence: value }

Installation

Follow the installation guide in the n8n community nodes documentation.

Local Development

To use this node in local development:

  1. Clone this repository
  2. Run npm install to install dependencies
  3. Run npm run build to compile the TypeScript code
  4. Link the package: npm link
  5. In your n8n installation directory, run: npm link n8n-nodes-secuencialgenerator
  6. Restart n8n

How It Works

The node performs mathematical operations on a sequence value. Each time the workflow executes, the operation is applied and the new value is returned.

Parameters

  • Operation Type: The mathematical operation to perform

    • Sum By: Adds the operational value to the current value
    • Multiply By: Multiplies the current value by the operational value
    • Subtract By: Subtracts the operational value from the current value
  • Operational Value: The value to use in the operation (must be an integer)

    • Supports expressions for dynamic values
    • Example: 1, 5, {{ $json.increment }}
  • Current Value: The current state of the sequence (must be an integer)

    • This should be set to the previous execution's output to maintain state
    • Supports expressions to reference previous values
    • Example: 0, {{ $json.sequence }}

Example Usage

Example 1: Simple Counter

First execution:

  • Operation Type: Sum By
  • Operational Value: 1
  • Current Value: 0
  • Output: { sequence: 1 }

Second execution (using previous output):

  • Operation Type: Sum By
  • Operational Value: 1
  • Current Value: {{ $json.sequence }} (references previous output)
  • Output: { sequence: 2 }

Example 2: Multiply Sequence

First execution:

  • Operation Type: Multiply By
  • Operational Value: 2
  • Current Value: 1
  • Output: { sequence: 2 }

Second execution:

  • Operation Type: Multiply By
  • Operational Value: 2
  • Current Value: {{ $json.sequence }}
  • Output: { sequence: 4 }

Example 3: Countdown

First execution:

  • Operation Type: Subtract By
  • Operational Value: 1
  • Current Value: 10
  • Output: { sequence: 9 }

Maintaining State

To maintain state between executions, you need to:

  1. Store the output value (the sequence field) after each execution
  2. Reference this stored value in the Current Value parameter on the next execution using expressions like {{ $json.sequence }}

Common patterns include:

  • Using a Set node to store the value in a variable
  • Chaining the node output back to itself in loops
  • Storing the value in a database and retrieving it for the next execution

Validation

Both Operational Value and Current Value must be integers. The node will show an error if:

  • Non-integer values are provided
  • Values cannot be parsed as numbers
  • Expressions evaluate to non-integer values

Compatibility

This node was developed and tested with n8n version 1.x.

Resources

License

MIT

Discussion