Pipedream $.flow.exit, $.respond and other $ helpers in n8n
Updated 2026-10-21 · 6 min read
- n8n has no $ object. The same control lives in nodes and in what a Code node returns.
- $.flow.exit becomes return [] in the Code node, or an If or Filter node before it.
- $.respond becomes a Respond to Webhook node. The Webhook node must respond through it.
Pipedream code steps steer the workflow through the $ object. $.flow.exit() stops the run. $.respond() answers the HTTP caller. $.export() shares data with later steps, and $.flow.delay() pauses the run.
n8n has no $ object for this. The same control lives in nodes and in what a Code node returns. This page maps each helper to n8n, with code before and after. It also shows the cases where you change the workflow, not just the code.
What to do now
- Find the helpers in your code. Paste a step into the free Code node compatibility check. It shows what the step uses.
- Replace
$.flow.exitwithreturn []in the Code node. If the condition is simple, use an If or Filter node in front of the step instead. - Move each
$.respondinto a Respond to Webhook node. Set the Webhook node to respond through that node first. - Turn delays, suspends and reruns into nodes or node settings. A Code node can't pause. Split the step and put a Wait node between the two halves.
Quick mapping
| Pipedream | n8n |
|---|---|
return $.flow.exit("reason") |
return [] in the Code node, or an If / Filter node |
$.respond({ status, headers, body }) |
Respond to Webhook node (Webhook set to "Using 'Respond to Webhook' Node") |
$.respond({ immediate: true, ... }) |
Respond to Webhook, placed early |
$.export("name", value) |
A field on the item the node returns |
return value ($return_value) |
return [{ json: value }] |
$.flow.delay(ms) |
Wait node between two nodes |
$.flow.suspend() + resume_url |
Wait node "On Webhook Call" + $execution.resumeUrl |
$.flow.rerun(delay, ctx, max) |
Retry On Fail, or Wait + If + loop |
$.flow.trigger() (alpha) |
Execute Sub-workflow node |
$.send.http(...) |
HTTP Request node |
$.service.db |
Data Table node, or workflow static data |
Pipedream documents these helpers on its Node.js and triggers pages.
$.flow.exit
In Pipedream, return $.flow.exit("no email") ends the run at once. Later steps don't run.
// Pipedream
export default defineComponent({
async run({ steps, $ }) {
const body = steps.trigger.event.body;
if (!body.email) return $.flow.exit("no email");
return { email: body.email };
},
});
In n8n, data moves from node to node as items. An item is one record. A Code node that returns no items ends its branch: the nodes after it get nothing and don't run.
// n8n Code node, Run Once for All Items
const body = $('Webhook').first().json.body;
if (!body.email) return [];
return [{ json: { email: body.email } }];
Two things work differently:
- The execution succeeds in n8n. It just has no more work. Should the stop count as a failure and alert someone? Then use a Stop and Error node instead.
- The exit reason is not recorded. Did you rely on it in Pipedream's event history? Then don't return an empty array. Return an item with the reason and send it to a logging node.
When the condition is simple, put an If or Filter node in front of the step. Then remove the exit from the code. The node is visible on the canvas, return [] is not.
$.respond
Pipedream's $.respond({ status, headers, body }) answers the HTTP request that started the workflow. Without immediate: true, the response goes out when the workflow ends. With it, the response goes out right away. Without any $.respond, Pipedream returns 200 with a "Success!" page.
n8n splits this into two settings:
- Webhook node > Respond: set it to Using 'Respond to Webhook' Node.
- Respond to Webhook node where the answer should go. It has Respond With JSON, plus the Response Code and Response Headers options.
// Pipedream
await $.respond({
status: 201,
headers: { "X-Request-Id": steps.trigger.event.headers["x-request-id"] },
body: { id: steps.create.$return_value.id },
});
In n8n, add a Respond to Webhook node after the "create" node and set:
- Respond With: JSON
- Response Code: 201
- Response Headers:
X-Request-Id={{ $('Webhook').first().json.headers['x-request-id'] }} - Response Body:
{{ { "id": $('create').first().json.id } }}
Immediate vs at the end
| Pipedream | Where the node goes in n8n |
|---|---|
$.respond({...}) (default) |
Respond to Webhook as the last node |
$.respond({ immediate: true, ... }) |
Respond to Webhook early; the work continues after it |
The n8n docs let you place the node anywhere. In our tests the response goes out when the node runs, and the nodes after it keep going. If the workflow fails before it reaches the node, the caller gets a 500 (Respond to Webhook docs). Only the first Respond to Webhook node that runs counts.
$.respond then $.flow.exit
A common Pipedream pattern: check the input, respond with an error, exit.
if (!body.email) {
await $.respond({ status: 400, body: { error: "email required" } });
return $.flow.exit("invalid");
}
In n8n, an If node does this. Its condition: email is not empty.
- False branch: a Respond to Webhook node with code 400. The branch ends there.
- True branch: the workflow continues and responds with 200 at the end.
$.export and return values
// Pipedream
$.export("domain", email.split("@")[1]);
return { email };
// later: steps.parse.domain, steps.parse.$return_value.email
// n8n
return [{ json: { email, domain: email.split('@')[1] } }];
// later: $('parse').first().json.domain, $('parse').first().json.email
Give each node the same name as its Pipedream step. Then the references translate one to one.
$.flow.delay and $.flow.suspend
$.flow.delay(ms) paused the workflow at the end of the step, for 1 ms up to one year. It returned a cancel_url and a resume_url (delay docs). $.flow.suspend() waited until someone called the resume_url. By default it was cancelled after 24 hours.
Neither can happen inside an n8n Code node. Split the step in two and put a Wait node between the halves:
- for a delay, set Resume to After Time Interval;
- for a suspend, set Resume to On Webhook Call.
For waits of 65 seconds or more, the Wait node offloads executions (Wait node docs).
$.flow.rerun
$.flow.rerun(delay, context, maxRetries) ran a step again. People used it to poll a job or to retry an API call (rerun docs). n8n has no single equivalent. Pick by what you used it for:
| Pipedream use | n8n |
|---|---|
| Retry on a short-lived error | Node Settings: Retry On Fail, Max Tries, Wait Between Tries |
| Poll until a job finishes | HTTP Request → If (done?) → Wait → back to HTTP Request, with a counter to stop |
| Wait for a callback | Wait node, On Webhook Call |
What our converter does with $
Our converter keeps your code. It wraps the code in a Code node that provides a $ object:
$.exportand return values become fields on the output item. Step names stay as node names, sosteps.x.yreferences still work.$.flow.exitworks. The wrapped step returns no items.$.respondis captured. The converter adds a Respond to Webhook node after the step and sets the Webhook node to respond through it. Status and body are carried over. Custom headers you set by hand on the Respond to Webhook node. If the step exits right after responding, the response is still sent.$.flow.delayand$.flow.rerunshow up in the report as manual work. If the wrapped step reaches one of them, it throws a clear error.$.flow.triggeris not converted or reported yet. A wrapped step that calls it fails when it runs. Search your code for it and rebuild those calls as Execute Sub-workflow nodes.
Run the whole export through the converter. The report and 1 workflow are free. Full export: $3 per workflow, $1 each after 50, $19 minimum, one-off. The rest of the code-step mapping is in Pipedream code steps to n8n.
Not affiliated with Pipedream or n8n.
FAQ
What is the n8n equivalent of $.flow.exit()?
Return an empty array from the Code node. The following nodes get no items and don't run. If the condition is easy to express, an If or Filter node before the step does the same without code.
How do I replace $.respond() in n8n?
Set the Webhook node's Respond option to Using 'Respond to Webhook' Node. Then add a Respond to Webhook node where the response should be sent. You set status, headers and body in that node.
How do I respond immediately like $.respond({ immediate: true })?
Place the Respond to Webhook node early in the workflow. The caller gets the response when it runs. In our tests the nodes after it keep running.
Is there an n8n equivalent of $.flow.rerun()?
Not a direct one. For retries, use Retry On Fail on the node. For polling, use a Wait node plus an If node that loops back.
What replaces $.export() in n8n?
Return the value as a field of the output item. Later nodes read it with $('Step name').first().json.field.
Sources (7)
- https://pipedream.com/docs/workflows/building-workflows/code/nodejs
- https://pipedream.com/docs/workflows/building-workflows/triggers
- https://pipedream.com/docs/workflows/building-workflows/code/nodejs/delay
- https://pipedream.com/docs/workflows/building-workflows/code/nodejs/rerun
- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook
- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait
- https://docs.n8n.io/build/understand-workflows/workflow-components/work-with-nodes