Use this file to discover all available pages before exploring further.
If you’ve been building with n8n and are ready to move to code-first workflows, this guide is for you. This page maps them to their Trigger.dev equivalents and walks through common patterns side by side.Your task code runs on Trigger.dev’s managed infrastructure, so there are no servers for you to provision or maintain.
In n8n you use a Webhook trigger node, which registers a URL that starts the workflow.In Trigger.dev, your existing route handler receives the webhook and triggers the task:
import { processWebhook } from "@/trigger/process-webhook";export async function POST(request: Request) { const body = await request.json(); await processWebhook.trigger({ event: body.event, data: body.data, }); return Response.json({ received: true });}
In n8n you use the Wait node to pause a workflow for a fixed time or until a webhook is called.In Trigger.dev:
trigger/send-followup.ts
import { task, wait } from "@trigger.dev/sdk";export const sendFollowup = task({ id: "send-followup", run: async (payload: { userId: string; email: string }) => { await sendWelcomeEmail(payload.email); // wait for a fixed duration, execution is frozen, you don't pay while waiting await wait.for({ days: 3 }); const hasActivated = await checkUserActivation(payload.userId); if (!hasActivated) { await sendFollowupEmail(payload.email); } },});
To wait for an external event (like n8n’s “On Webhook Call” resume mode), use wait.createToken() to generate a URL, send that URL to the external system, then pause with wait.forToken() until the external system POSTs to that URL to resume the run.
trigger/approval-flow.ts
import { task, wait } from "@trigger.dev/sdk";export const approvalFlow = task({ id: "approval-flow", run: async (payload: { requestId: string; approverEmail: string }) => { // create a token, this generates a URL the external system can POST to const token = await wait.createToken({ timeout: "48h", tags: [`request-${payload.requestId}`], }); // send the token URL to whoever needs to resume this run await sendApprovalRequest(payload.approverEmail, payload.requestId, token.url); // pause until the external system POSTs to token.url const result = await wait.forToken<{ approved: boolean }>(token).unwrap(); if (result.approved) { await executeApprovedAction(payload.requestId); } else { await notifyRejection(payload.requestId); } },});