Docs / Strand / nodes/function-call

Function Call Node

Execute reusable functions from your function library within workflows.

The Function Call node's Configuration, selecting a saved function from the library. The node references a function by id; editing the function changes every workflow that calls it.

Overview

Function Call nodes allow you to invoke pre-defined, reusable Python functions stored in your account's function library. This promotes code reuse and keeps workflows clean.

The Functions editor: code pane, test payload, and a reference panel listing available modules and builtins The function library editor under Functions. The reference panel on the right is the authoritative list of what the sandbox allows, and the Test Payload pane runs the function against sample input before you save it.

Use Cases
  • Reusable data transformations
  • Shared validation logic
  • Common calculations across workflows
  • Centralized business rules

Available Variables

Functions use the same secure execution environment as Python Snippets:

Available in Functions

NOT Available in Functions

Functions vs Python Snippets

Functions are identical to Python Snippets in terms of:

  • Available variables (payload, meta, vault)
  • Execution environment (same sandbox)
  • Allowed libraries and restrictions

The only difference is functions are reusable across multiple workflows.

Any vault values in output are automatically replaced with {{ vault.key }} placeholders.

Configuration

Field Type Required Description
function_id string Yes ID of the function to execute

How It Works

  1. Select a function from your function library
  2. The function receives the current event's payload and meta
  3. Function code executes in the same secure sandbox as Python Snippet nodes
  4. The function's return value becomes the next node's payload

Creating Functions

Functions are created and managed in the Functions page:

  1. Navigate to Functions from the sidebar
  2. Click "Create Function"
  3. Give your function a name and description
  4. Write your Python code
  5. Save the function

Function Code Structure

Function code follows the same structure as Python Snippet nodes:

python

# Access input data
user_id = payload.get('user_id')
email = payload.get('email', '')

# Process data
email_normalized = email.lower().strip()
is_valid = '@' in email and '.' in email.split('@')[1] if email else False

# Return result
return {
    'user_id': user_id,
    'email': email_normalized,
    'is_valid': is_valid
}

Available Libraries

Functions can import the same safe libraries as Python Snippets:

Category Libraries
Data Formats json, csv, base64, html
Math & Numbers math, decimal, statistics, random
Date/Time datetime
Text Processing re, string, textwrap
Data Structures collections, itertools, functools, operator
Utilities hashlib, uuid
URL Handling urllib.parse

Using Functions in Workflows

Adding a Function Call Node

  1. Open the Node Selector panel
  2. Expand the Functions category
  3. Drag a function onto the canvas, or click to add
  4. The function is automatically configured with the selected function

Accessing Function Output

The function's output is available to downstream nodes:

jinja

{{ payload.result }}
{{ payload.is_valid }}

Or when accessing from non-directly connected nodes:

jinja

{{ steps.function_call_node.output_payload.result }}

Examples

Email Validation Function

Function Name: validate_email

Code:

python


email = payload.get('email', '')

# Email regex pattern
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
is_valid = bool(re.match(pattern, email))

# Extract domain
domain = email.split('@')[1] if is_valid else None

return {
    'email': email,
    'is_valid': is_valid,
    'domain': domain
}

Usage in Workflow:

code

[HTTP Trigger] -> [Function: validate_email] -> [Logic: if_else] -> ...

Data Normalization Function

Function Name: normalize_user_data

Code:

python

user = payload.get('user', {})

return {
    'id': user.get('id'),
    'full_name': f"{user.get('first_name', '')} {user.get('last_name', '')}".strip(),
    'email': user.get('email', '').lower(),
    'created_at': meta.get('received_at')
}

Calculate Order Total Function

Function Name: calculate_order_total

Code:

python

items = payload.get('items', [])
tax_rate = payload.get('tax_rate', 0.08)

subtotal = sum(
    item.get('price', 0) * item.get('quantity', 1)
    for item in items
)
tax = subtotal * tax_rate
total = subtotal + tax

return {
    'subtotal': round(subtotal, 2),
    'tax': round(tax, 2),
    'total': round(total, 2),
    'item_count': len(items)
}

Function Call vs Python Snippet

Feature Function Call Python Snippet
Code Location Stored in function library Inline in workflow
Reusability Reusable across workflows Single workflow only
Maintenance Update once, affects all uses Update each workflow
Security Same sandbox restrictions Same sandbox restrictions
Performance Same execution model Same execution model
When to Use Functions
  • Use Functions when you need the same logic in multiple workflows
  • Use Python Snippets for one-off transformations specific to a workflow

Security

Function Call nodes execute in the same secure sandbox as Python Snippet nodes, with the same restrictions and resource limits. Vault secrets are accessible via the vault variable, but any vault values in output are automatically replaced with {{ vault.key }} placeholders.

Limitations

Best Practices

Tips
1

Use descriptive function names

validate_email, calculate_total, not func1

2

Add descriptions

Document what the function does

3

Keep functions focused

Single responsibility principle

4

Handle missing data

Use .get() with defaults

5

Test functions

Verify with sample data before using in workflows

6

Version control

Track changes to important functions

7

Document inputs/outputs

Add comments explaining expected data