Skip to content
synthreo.ai

Custom Script

Custom Script node for Builder — write and execute custom JavaScript or Python code inline within a workflow to implement bespoke logic, transformations, or integrations not covered by built-in nodes.


The CustomScript node allows you to execute custom code inside ThreoAI workflows.
It supports Python, enabling complex data processing, calculations, integrations, and business logic beyond standard nodes.

  • Data from previous workflow nodes is passed into the script.
  • Script output is passed to the next workflow node.
  • Must be wrapped inside a unique JSON object name (e.g., {"custom_result": {...}}).

Output Format (example): json { "custom_result": { "processed": true, "score": 95, "status": "approved" } }

NameTypeRequiredDefaultDescription
Script ContentCode editorEmptyPython/JavaScript code executed by this node.
Programming Language (language)DropdownPythonDefautl to Python.
Script Encryption (encryption)ToggleOptionalOffProtects script code with encryption.
Encryption Password (password)PasswordRequired if encryption enabledEmptyPassword required to view/edit encrypted scripts.
  • Loyalty Points Calculator (Python): Apply custom rules combining purchase data, customer tiers, and seasonal bonuses.
  • Invoice Validation: Flag incomplete or suspicious invoice data before payment processing.
  • Sales Analytics: Calculate growth rates, quotas, and rankings across multiple data sources.
  • Start with simple scripts and test often.
  • Apply error handling (try/except) to avoid workflow failures.
  • Always return results wrapped in a unique JSON object name.

Each Python script must define an execute function as the entry point:

def execute(input_json, meta):
# input_json: data received from the previous node
# meta: metadata provided by the workflow engine
# Example: echo input with added field
result = {
"custom_result": {
"original": input_json,
"processed": True
}
}
return result
```text
### Rules
- `input_json`: Contains data passed from the previous node.
- `meta`: Contains workflow context and metadata.
- Output must be wrapped in a **unique JSON object name** (e.g., `"custom_result"`) to avoid collisions with other nodes.
- The return value must be JSON-serializable.