Most of what I need is covered by built-in steps, but every so often I just want to drop into real code for a bit of custom logic. How do I run custom TypeScript or Python in a step in 3B? How does data get in and out, and what can I actually do inside one?
Great question on dropping into code when the built-in steps don’t quite cover it.
Running custom code
A code step runs your TypeScript or Python in a sandbox. You write the logic in the step’s script file, and it executes as part of the flow like any other step.
Data in
- Reference the output of earlier steps as your input, passed in when the step runs.
- Read environment variables, including credentials injected by any connectors attached to the step, so you never hardcode secrets.
- For large payloads, read from a file or volume rather than passing it inline.
Data out
- Whatever your script returns (or prints as structured output) becomes the step’s output, which later steps reference.
- Return clean JSON in a stable shape so downstream steps can rely on it.
What you can do inside
- Transform, parse, filter, and reshape data the built-in steps handle awkwardly.
- Make authenticated HTTP requests to any connector attached to the step.
- Custom logic: math, date handling, regex, branching, dedup, validation.
- Pull in libraries for the heavy lifting.
- Read and write files or a persistent volume for state across runs.
Best used as small, focused steps: drop into code for the one thing that needs it, then hand a clean result back to the rest of the flow.