Package Information
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:
- Sum By: Add a value to the current sequence
- Multiply By: Multiply the current sequence by a value
- 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:
- Clone this repository
- Run
npm installto install dependencies - Run
npm run buildto compile the TypeScript code - Link the package:
npm link - In your n8n installation directory, run:
npm link n8n-nodes-secuencialgenerator - 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:
- Store the output value (the
sequencefield) after each execution - Reference this stored value in the
Current Valueparameter 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