Node Functions
The Luau scripting integration provides access to all specialty node functionality as callable functions. This allows you to use node capabilities either through visual nodes in the flow editor or through function calls in Luau scripts, giving you flexibility to choose the best approach for your workflow.
Overview
All node functions are automatically registered and organized by category. Functions are available in the global namespace using the pattern:
Category.functionName(...)
For example:
Math.add(5, 3)- Adds two numbersString.concat("Hello", " World")- Concatenates two stringsGit.clone(url, path)- Clones a git repository
Function Organization
Functions are organized by node category:
- Math Functions - Mathematical operations (add, subtract, multiply, etc.)
- String Functions - String manipulation (concat, substring, etc.)
- Conversion Functions - Type conversions (stringToInteger, etc.)
- Cryptography Functions - Cryptographic operations (hash, hmac, sign)
- File Operations - File system operations (exists, getFiles, etc.)
- Git Functions - Git operations (clone, pull, commit, etc.)
- YAML Functions - YAML parsing and generation
- JSON Functions - JSON parsing and validation
- CSV Functions - CSV parsing and generation
- INI Functions - INI file parsing and generation
- Semver Functions - Semantic versioning operations
- OpenAI Functions - OpenAI API integration
- Comparison Functions - Comparison operations
Parameter Passing
Functions support two parameter passing styles:
Positional Parameters
local result = Math.add(5, 3)
Named Parameters (via table)
local result = Math.add({A = 5, B = 3})
Return Values
-
Single output: Returns the value directly
local sum = Math.add(5, 3) -- Returns 8 -
Multiple outputs: Returns a table with named keys
local result = Git.clone(url, path)
-- result.Success = true/false
-- result.RepositoryPath = "/path/to/repo"
Type Conversion
The system automatically converts between Lua types and node pin types:
- Lua
string→ nodestringpin - Lua
number→ nodenumber/integer/floatpin (auto-detected) - Lua
boolean→ nodebooleanpin - Lua
table→ JSON string for complex types
Outputs are converted back to appropriate Lua types:
booleanpins → Lua booleannumber/integer/floatpins → Lua numberstringpins → Lua string
Error Handling
Functions use Lua's standard error handling. If a function fails, it will raise an error that can be caught with pcall:
local success, result = pcall(function()
return Math.add(5, 3)
end)
if not success then
print("Error: " .. result)
end
Nodes Not Available as Functions
The following node types are not exposed as functions (they are flow control mechanisms):
- Event nodes: ButtonEvent, CronEvent, MCPTriggered, OpenAITriggered
- Control flow nodes: Branch, Sequence, Foreach, DoN
- Flow terminators: Success, Failed
- Workflow trigger: TriggerFlow (use
triggerWorkflow()function instead)
Examples
Math Operations
local sum = Math.add(10, 20)
local product = Math.mul(5, 6)
local power = Math.pow(2, 8)
String Operations
local combined = String.concat("Hello", " World")
local left = String.left("Hello World", 5) -- Returns "Hello"
local right = String.right("Hello World", 5) -- Returns "World"
File Operations
if File.exists("config.json") then
local content = File.loadText("config.json")
print(content)
end
Git Operations
local result = Git.clone("https://github.com/user/repo.git", "./repo")
if result.Success then
print("Cloned to: " .. result.RepositoryPath)
end
Compatibility with Existing APIs
Some functionality is available through both node functions and existing Luau APIs:
- File operations:
FlowFile.read/write/exists/listvsFile.*functions - YAML:
parseYamlString/parseYamlFilevsYAML.*functions - JSON:
parseJsonString/parseJsonFilevsJSON.*functions - CSV:
parseCsvString/parseCsvFilevsCSV.*functions - INI:
parseIniString/parseIniFilevsINI.*functions
Both APIs are maintained for backward compatibility. Node functions are recommended for consistency with the visual node system.