Script Steps

Write inline Lua or Ale scripts that run in the engine itself. Use them for small data transforms, derived fields, and routing logic where spinning up an external service would be overkill.

Languages

Argyll supports two script languages:

  • Lua is the recommended default. Familiar imperative syntax, sandboxed (io, os, debug modules excluded).
  • Ale is Argyll’s native Lisp-like language. Purely functional, no I/O, safe for untrusted scripts.

Examples here use Lua.

Inputs and Outputs

A script’s input Attributes are exposed as variables. The script must return a table whose keys are the Step’s output Attribute names.

{
  "id": "format-name",
  "type": "script",
  "script": {
    "language": "lua",
    "script": "return {display_name = first_name .. \" \" .. last_name}"
  },
  "attributes": {
    "first_name": { "role": "required", "type": "string" },
    "last_name": { "role": "required", "type": "string" },
    "display_name": { "role": "output", "type": "string" }
  }
}

Examples

Calculation with Conditional

local subtotal = quantity * unit_price
local tax = subtotal * 0.08
local shipping = quantity > 5 and 0.0 or 9.99
return {
  subtotal = subtotal,
  tax = tax,
  shipping = shipping,
  total = subtotal + tax + shipping,
}

Decision Logic

local eligible = age >= 18 and credit_score >= 600
return {
  eligible = eligible,
  risk_level = credit_score >= 750 and "low"
            or credit_score >= 650 and "medium"
            or "high",
}

String Formatting

return {
  formatted_text = "[" .. name .. "] " .. text,
}

When to Use Scripts

  • Data transformation between steps
  • String and number formatting
  • Routing decisions and gating logic
  • Building structured output from existing inputs

Keep scripts small. Complex business logic belongs in external services where it can be tested, versioned, and instrumented properly.