run

Triggers another script to run asynchronously. The triggered script runs independently in the background, and you can pass data to it via a payload object.

{% json payload %}
  {
    "order_id": {{ order.id }},
    "customer_email": "{{ customer.email }}"
  }
{% endjson %}

{% run "process_order", payload %}

Syntax

{% run "script_handle", payload %}
{% run "script_handle", payload, delay: seconds %}
{% run script_variable, payload %}

Parameters

Parameter
Required
Description

script_handle

Yes

Handle or ID of the script to trigger (string in quotes or variable)

payload

No

Object containing data to pass to the triggered script

delay

No

Number of seconds to wait before running the script

Behavior

  • The triggered script runs asynchronously (the current script continues immediately)

  • Payload variables become directly accessible in the triggered script

  • The script must exist and be active

  • Recursive runs are prevented (a script cannot trigger itself directly or through a chain)

  • If the script is not found, a warning is logged

Examples

Basic script trigger:

Trigger with payload:

In the triggered script (order_processor), access the variables directly:

Trigger with delay:

Dynamic delay based on condition:

Trigger script using variable for handle:

Chain multiple scripts:

Conditional script trigger:

Pass complex nested data:

Scheduled batch processing:

Trigger by script ID:

Error handling pattern:

Use Cases

Scenario
Description

Background processing

Offload heavy tasks to run asynchronously

Delayed actions

Schedule follow-ups, reminders, or retries

Event fan-out

Trigger multiple scripts from a single event

Modular workflows

Break complex processes into smaller scripts

Error handling

Trigger dedicated error handling scripts

Batch processing

Process large datasets with controlled timing

Notes

  • The current script does not wait for the triggered script to complete

  • Recursive runs are blocked - a script cannot directly or indirectly trigger itself

  • If the script handle is not found, a warning is logged but execution continues

  • The script must be active to be triggered

  • Use the delay parameter for rate limiting or scheduling

  • Payload data is passed as-is - ensure proper JSON formatting

  • Both script handle (name) and script ID can be used to reference the script

Last updated