Skip to main content
Register custom utility functions for use in workflows.

Overview

Functions are implemented in Go and exposed to the Goja JavaScript VM runtime in internal/functions/.

Function Registry

Functions are registered in internal/functions/goja_runtime.go:

Steps to Add a Function

1. Implement the Function

Add to an appropriate file in internal/functions/:

2. Register the Function

Update internal/functions/goja_runtime.go:

3. Add to Function List

Update internal/functions/registry.go for ListFunctions():

4. Write Tests

Add to internal/functions/registry_test.go:

Return Types

String

Boolean

Number

Array

Object/Map

Working with Context

Functions can access the execution context:

Example: Hash Function

Register:
Usage in workflow:

Example: HTTP Fetch Function

Usage:

Best Practices

  1. Validate arguments - Check argument count and types
  2. Handle errors gracefully - Return undefined for errors
  3. Document the function - Add to ListFunctions()
  4. Write tests - Cover happy path and edge cases
  5. Keep functions pure - Minimize side effects
  6. Support optional arguments - Use sensible defaults

Function Categories

Organize functions by category:

Next Steps