Tailflow
Skip to article
Browse documentation

Code · Action

Run JavaScript

Runs JavaScript you write against the event, and hands what it returns to the steps below. The escape hatch for anything a filter cannot express.

When to use it

When a filter cannot express what you mean, or a message needs a number the event does not carry — a ratio, a running total, a threshold that depends on two fields.

At a glance

IntegrationCode
Credits2
ConnectionNone

Settings

scriptRequired
JavaScript. Reads input.event and input.actions, and returns a value.

Read input, return output

Use input.event for the triggering event and input.actions for earlier outputs on this path. Return a JSON-compatible value, usually an object with named fields.

Write JavaScript directly; do not insert {{ }} templates into the script. The script cannot make network requests or access files and has one second to finish. Keep its returned output below 64 KB.

Each run starts fresh. There is no persistent state for a running total across different events; calculations are limited to the event and earlier outputs supplied to this run.

Transform Input and Script Editor
Event shape
value_decimal
125000
token_symbol
USDC
Transform · Script
Example. Event fields and earlier action outputs are available through input. Return an object to expose named fields to the next action.Changes stay in this example. Nothing is saved or sent.

Example

This creates a concise summary while preserving amounts as text. It does not convert large token values to JavaScript numbers, which could lose precision.

Transform Action Configuration
Path 1
Every event
Transform
Selected action
1Transform
Sample output
actions.transform_1.summary
125000 tokens moved
Continue on error
A failure stops later actions on this path.
Example. Read the event through input.event and return an object. A test executes the script and lets you inspect the fields it returns.Changes stay in this example. Nothing is saved or sent.
JavaScript
return {
  summary: `${input.event.value_decimal} ${input.event.token_symbol} transferred`,
  link: input.event.explorer_tx_url
};

Use and test the result

A later message can read {{ actions.transform_1.summary }} and {{ actions.transform_1.link }}. The output key is shown in the inspector.

Transform executes during Validate run, so you can inspect its actual result. A script error, excessive runtime, or oversized output fails the action and stops the path unless Continue on error is enabled.

Email Configuration with Transform Output
Transform · Output
actions.transform_1.summary
125000 USDC transferred
actions.transform_1.link
https://example.com/transaction
Email · Body
Rendered
125000 USDC transferred https://example.com/transaction
Example. Select an output from the earlier Transform action, then test the message. The action must be above the message on the same path.Changes stay in this example. Nothing is saved or sent.

What it hands on

Actions run in order, and each one can read what the actions above it produced. This one writes the fields below; a later action reaches them as {{ actions.transform_1 }} — the action’s key, then which one it is if you use more than one of the same kind.

(whatever you return)
The value your script returns, read by the steps below as actions.transform_1. Return an object and its keys are reachable with a dotted path.

One second, and no network

Scripts run in a sandbox with no way to reach anything outside the event, and are stopped after a second. What it returns is what the steps below it read.