EN
Lesson 4.1

Workflow Automation: n8n, Zapier and Trigger.dev - What to Use When

Choose the right automation platform for a job and generate workflow JSON with your agent

26 minAutomation and Agentic SystemsAvailable

What you learn

  • When to use n8n, Zapier or Trigger.dev for an automation
  • Self-hosting n8n on a cheap VPS to escape per-task pricing
  • Generating workflow JSON with your agent instead of clicking through a UI

Summary

Before you build a custom app, ask whether a workflow tool can do the job in an afternoon. Automation platforms sit between your services and fire a chain of steps whenever something happens: a form is submitted, a row changes, a timer ticks. The three that matter in 2026 are Zapier (easiest, hosted, pay per task), n8n (flexible, self-hostable, the builder favourite) and Trigger.dev (code-first jobs that live next to your app). This lesson gives you a decision rule, the real cost picture, and the trick that makes all of them faster: have your agent write the workflow JSON instead of dragging nodes around.

What you will learn

You will learn how the three platforms differ in philosophy and cost, why self-hosting n8n on a 5 to 10 dollar VPS often beats per-task pricing once volume grows, when Trigger.dev is the right call, and how to describe a workflow to Claude Code and get importable JSON back. By the end you can pick a platform in seconds and stand one up the same day.

Prerequisites

Courses 1 to 3. You need the API and webhook basics, a comfort with environment variables and secrets, and ideally a deployed project from Course 3 so an automation has something real to talk to. If the words trigger, webhook and cron are not yet second nature, skim the Fundamentals page on what an API is first.

The problem

Beginners reach for one of two extremes. Either they wire everything into Zapier, watch the per-task bill climb as volume grows, and feel trapped. Or they decide to build a custom backend for a job that is really just "when a Typeform comes in, add a row and send a Slack message" - three weeks of work for something a workflow tool does in twenty minutes. The skill is knowing which jobs are workflow-shaped and which platform fits the control, cost and code you actually want.

Choosing a platform

Think in three questions: how much do you care about cost at volume, how much control do you need, and how much code are you willing to write. Zapier optimises for getting live in five minutes with thousands of pre-built integrations. n8n optimises for flexibility and cost control because you can self-host it. Trigger.dev optimises for developers who want their background jobs versioned in their own repo. Match the platform to the answer, not to brand familiarity.

  • Zapier: hosted, the easiest, the widest integration catalogue. Pricing is per task (every step that runs counts), which is fine at low volume and painful at high volume. Use it for quick glue between SaaS tools where you run hundreds of tasks a month, not millions.
  • n8n: open-source and self-hostable, a visual node editor like Zapier but you own the instance. Hosted cloud option exists, but the win is running it yourself for a flat VPS cost. Use it when volume is real, you want full control, or you need custom code inside steps.
  • Trigger.dev: code-first. You write background jobs in TypeScript in your own repo, with retries, scheduling and long-running tasks handled for you. Use it when the automation is really part of your app and belongs in version control next to it, not in a separate clicky UI.
  • Rule of thumb: prototype in Zapier, graduate high-volume glue to self-hosted n8n, and put app-coupled jobs in Trigger.dev.

The cost trap and self-hosting n8n

Per-task pricing is the thing that bites you. A workflow with six steps that runs 5,000 times a month is 30,000 tasks, and on a hosted plan that adds up fast. Self-hosting n8n flips this to a flat cost: a small VPS on a provider like Hostinger, Hetzner or a basic DigitalOcean droplet runs roughly 5 to 10 dollars a month and will happily execute tens of thousands of workflow runs. You trade a little setup for predictable cost and full control, including custom code nodes and access to your own database on the same box. Here is a minimal Docker Compose sketch to stand n8n up with a persistent volume so your workflows survive a restart.

# docker-compose.yml - minimal self-hosted n8n on a small VPS
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - '5678:5678'
    environment:
      - N8N_HOST=your-domain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://your-domain.com/
      # Always set basic auth or put it behind a reverse proxy
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
    volumes:
      # Persist credentials and workflows across restarts
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
A starting docker-compose.yml for self-hosted n8n. Put it behind a reverse proxy with HTTPS and never expose it without auth.

Run it with docker compose up -d, point a subdomain at the box, and put it behind a reverse proxy (Caddy or Nginx) for HTTPS. The security mindset from Course 3 applies: an open n8n instance with no auth is a remote-code-execution machine for anyone who finds it. Lock it down before you put a single credential in it.

Generating workflow JSON with your agent

Here is the part that makes you faster than people who live in these builders. n8n and Zapier both store workflows as JSON under the hood. That means you do not have to drag nodes around at all - you can describe the workflow to Claude Code, have it produce the JSON, and import it. For anything beyond three steps this is dramatically quicker, and it puts your automation in a file you can version, diff and reuse. The trick is giving the agent the node schema to follow, which you get by exporting one example workflow from the UI first.

## Goal
An n8n workflow JSON I can import directly.

## Trigger
Webhook node. It receives a POST with { email, name, plan }.

## Steps
1. Validate that email contains "@"; if not, respond 400.
2. Insert a row into Postgres (table: leads) with the three fields plus a created_at timestamp.
3. Send a Slack message to #new-leads: "New lead: {name} on {plan}".
4. Respond 200 with { ok: true }.

## Constraints
- Match the exact node JSON structure of the example I pasted below.
- Use n8n expression syntax ={{ $json.email }} for field references.
- Do not invent credential IDs; leave them as placeholders I will fill in.

## Example node structure
<paste one exported workflow here so the agent copies the real schema>
A spec you can hand to Claude Code to get importable n8n workflow JSON. Always paste one real exported example so it matches the current schema.

The same pattern works for Trigger.dev, except the output is TypeScript in your repo rather than JSON in a UI, which is even more natural for an agent. Always import the generated JSON into a test workflow first and run it once before trusting it in production, because node schemas drift between n8n versions and the agent works from whatever example you gave it.

Typical mistakes

The recurring errors: defaulting to Zapier for everything and discovering the per-task bill only at scale; self-hosting n8n with no auth and no HTTPS, which is a security hole, not a saving; building a custom app for a job that was always workflow-shaped; and trusting agent-generated JSON without importing and running it once. Also watch for putting secrets directly in workflow nodes instead of the platform credential store - that leaks them on every export.

Business ROI

Workflow tools are the highest-leverage automation you can ship without writing a backend. A single n8n flow can replace a part-time job: receive leads, enrich them, route them, notify a human, log everything. Moving high-volume glue from per-task Zapier to a self-hosted n8n box can cut a recurring bill from hundreds of dollars a month to under ten, with no loss of capability. And generating the JSON with your agent compresses a half-day of clicking into a ten-minute spec, so you build five automations in the time others build one.

Checklist

You are ready to move on when you can answer these without hesitation, because the rest of this course assumes you can stand up an automation.

  • Can you name the right platform for a quick SaaS glue job, a high-volume flow, and an app-coupled background job?
  • Do you know why per-task pricing hurts at scale and roughly what a self-hosted n8n VPS costs?
  • Can you stand up n8n with Docker Compose, behind auth and HTTPS?
  • Can you write a spec that gets importable workflow JSON out of your agent?

Resources

Bookmark the official n8n, Zapier and Trigger.dev docs, because node names and pricing change and you want the current source, not a memory. The n8n self-hosting and Docker docs are the canonical reference for the Compose setup above. When an agent-generated workflow misbehaves, your first move is always to export a fresh example from the running instance and re-prompt against it.

Your task

Pick one real, repetitive task in your work that fits the "when X happens, do Y and Z" shape. Build it twice: once by hand in a free Zapier or n8n account to feel the builder, then again by having your agent generate the JSON from a spec. Note which was faster and which you would actually maintain. That comparison tells you how you will build every automation from here.

Next lesson

Automations constantly need to act on websites that have no API. The next lesson covers browser automation and scraping with Playwright, the non-headless manual-login trick, and the .har trick for finding the real API hiding behind a page.

Comments

Loading comments.

Post a comment
CommentsNext
Next step

Ready to put AI to work as a real workflow?

Start with the foundations course, keep your progress locally and sync everything to your free account whenever you like.