Workflow parameters are user-provided input values that:
$ prefix){
"version": "3.6",
"name": "UserDataProcessor",
"registry": {
"params": [
"userId(STRING)",
"maxRecords(INT)",
"config(OBJECT)"
],
"vars": [
"$processedData(OBJECT)",
"$recordCount(INT)"
]
},
"steps": [
{
"id": "Set_RecordCount",
"target": "$recordCount",
"value": "=maxRecords + 10",
"next": "Set_Data"
},
{
"id": "Set_Data",
"target": "$processedData",
"value": "{\"userId\": \"=userId\", \"limit\": \"=$recordCount\", \"host\": \"=config.host\"}",
"next": "Stop_End"
},
{
"id": "Stop_End"
}
]
}
// Define workflow with parameters
workflow := &workflow.Workflow{
Version: "3.6",
Name: "UserDataProcessor",
Registry: workflow.Registry{
Params: []string{
"userId(STRING)",
"maxRecords(INT)",
"config(OBJECT)",
},
Vars: []string{
"$processedData(OBJECT)",
"$recordCount(INT)",
},
},
Steps: []workflow.Step{
// ... steps as shown above
},
}
// Create engine
engine, _ := workflow.NewEngine(workflow)
// Execute with parameter values
result, _ := engine.Execute(
context.Background(),
map[string]interface{}{
"userId": "user123",
"maxRecords": 100,
"config": map[string]interface{}{
"host": "api.example.com",
"port": 443,
},
},
adapters,
)
Parameters can have type declarations similar to variables:
userId(STRING) - string parametermaxRecords(INT) - integer parameterconfig(OBJECT) - object parameter (automatically converts JSON strings to maps)items([STRING]) - array parameterOBJECT Parameter Conversion: When you declare a parameter as OBJECT type and pass a JSON string during workflow execution, it's automatically parsed and converted to a map[string]interface{}:
// Workflow declares config(OBJECT)
engine.Execute(ctx, map[string]interface{}{
"config": `{"host": "localhost", "port": 8080}`, // String input
}, adapters)
// Inside workflow, config is accessible as a map:
// "=config.host" → "localhost"
// "=config.port" → 8080
Parameters can be used in any expression:
// Direct reference
"=userId"
// Arithmetic
"=maxRecords + 10"
// String concatenation
"=userId + \"_processed\""
// Nested access
"=config.host"
// Comparisons
"=maxRecords > 100"
Attempting to modify a parameter will result in an error:
{
"id": "Set_Param",
"target": "userId",
"value": "newValue"
}
This will fail with: "cannot modify parameter: userId (parameters are read-only)"
$ prefix, read-only, passed at workflow execution$ prefix, mutable, can be modified during executionWhen executing a workflow, parameters can be passed through initialVars:
initialVars := map[string]interface{}{
"userId": "user123", // Parameter (no $ prefix)
"config": configObject, // Parameter
"$result": nil, // Variable ($ prefix)
}
engine.Execute(ctx, initialVars, adapters)
The engine will automatically:
registry.paramsExecutionContext.Params$ prefix) in ExecutionContext.Variables$ prefix added// If "unknownParam" is not in Params
"=unknownParam"
// Error: "parameter not found: unknownParam"
{
"target": "userId",
"value": "newValue"
}
// Error: "cannot modify parameter: userId (parameters are read-only)"
// If passing invalid JSON for OBJECT param
engine.Execute(ctx, map[string]interface{}{
"config": "not valid json", // Invalid JSON
}, adapters)
// Error: "failed to convert parameter config to OBJECT: ..."
Use Parameters for:
Use Variables for:
Naming Conventions:
userId, maxRecords)$ prefix (e.g., $result, $processedData)_ prefix (e.g., _item, _index)