IO Scripts: Introduction
IO Scripts let you run custom JavaScript logic inside a workflow: call external APIs, transform session data, enforce business rules that don't fit standard nodes.
What is an IO Script?
A Script node executes a named IO Script: a JavaScript module with a single exports.execute function. The function receives two objects:
lrObject: identity CRUD operations (get profile, update profile, read access token)hook: session read/write (form fields, request headers, query params, shared state)
The output edge is determined by whether the script calls hook.setError(). If the script completes without calling hook.setError(), the workflow follows the true output. If hook.setError() is called, the workflow follows the false output.
exports.execute = async (lrObject, hook) => {
// call hook.setError() to route to the false output
// complete without hook.setError() to route to the true output
};
Execution Model
When the Script node is reached, the workflow enqueues the script and shows a loading page while polling for the result. Once the script completes, the workflow evaluates the output and continues.
You can customize the loading page message with the Wait Page Description property on the Script node. If the Disable Cancel Button property is not set, a Cancel button is shown: clicking it routes the workflow to the false output immediately.
When to Use a Script Node
| Use this when… | Example |
|---|---|
| You need to call an external API mid-flow | Verify a government ID against a third-party service before creating a user |
| You need custom business logic | Block signups from certain email domains not covered by built-in validation |
| You need to set a custom field on the identity | Write a risk score to a custom attribute after Auth |
| You need to read session data and branch on it | Route to different MFA paths based on a query-parameter flag stored in session |
Creating and Attaching a Script
- In the Admin Console, navigate to Platform Config → IO Scripts.
- Click New Script, give it a name, and write your
exports.executefunction. - Save the script.
- In the workflow canvas, drag a Script node from the Service bucket in the node palette.
- In the Script node's properties panel, select your script from the Script dropdown.
- Wire the
trueandfalseoutputs to the appropriate downstream nodes.
Script nodes have a 5-second execution timeout. If the function does not return within 5 seconds, the workflow treats it as a false output. Use Promise.race with a timeout for unreliable third-party services.
Next Steps
- lrObject API: identity CRUD methods available inside every script
- Hook API: read and write session state from within a script
- Examples: three copy-ready patterns