DEV Community

Youvandra Febrial
Youvandra Febrial

Posted on

Getting started with n8n

Automate Like a Pro: Your First n8n Workflow in 5 Minutes 🚀

Ever felt like you’re writing the same boilerplate code over and over?

What if you could stitch together APIs, databases, and even your favorite Slack channel without pulling an all‑night hackathon?

Enter n8n – the open‑source workflow engine that lets you build “if‑this‑then‑that” automations with a visual canvas (and a dash of code when you need it).

In this post I’ll walk you through getting n8n up and running, creating a tiny but useful workflow, and dropping a few pro‑tips you can copy‑paste into your next project. Let’s dive! 🌊


1️⃣ Why n8n? (Quick TL;DR)

  • Open source – self‑host or use the managed cloud, no vendor lock‑in.
  • Node‑based UI – drag‑and‑drop, but you can also write custom JavaScript.
  • 100+ integrations – from GitHub to Google Sheets, all ready to go.
  • Runs everywhere – Docker, Vercel, Railway, even a Raspberry Pi.

If you’ve ever used Zapier or IFTTT, think of n8n as the “hacker‑friendly” cousin that gives you full control over inputs, outputs, and error handling.


2️⃣ Getting n8n Up & Running

2.1. Choose your playground

Option When to pick it Command
Docker (recommended) You want a one‑liner that works on any OS docker run -it --rm -p 5678:5678 n8nio/n8n
npm You already have Node.js installed and love CLI npm i -g n8n && n8n start
Managed Cloud No ops hassle, just sign‑up at https://app.n8n.io

Tip: If you’re on a Mac with Homebrew, you can also brew install n8n.

2.2. Verify the UI

Open your browser → http://localhost:5678 → you should see the n8n canvas with a friendly “Welcome to n8n!” banner. 🎉


3️⃣ Build Your First Workflow: “New GitHub Issue → Slack Alert”

3.1. High‑level steps

  1. Trigger – Listen for a new issue on a GitHub repo.
  2. Function – Add a custom emoji and format the message.
  3. Slack – Post the formatted text to a channel.

3.2. Step‑by‑step

3.2.1. Add the GitHub Trigger

  1. Click + → search “GitHub” → pick GitHub Trigger.
  2. Choose Event: Issue Created.
  3. Connect your GitHub account (OAuth flow).
  4. Set the Repository (e.g., myorg/my‑awesome‑repo).

3.2.2. Insert a Function Node

  1. Drag a Function node onto the canvas, link it to the GitHub trigger.
  2. Paste this JavaScript snippet:
// n8n Function node – transform GitHub payload into a Slack message
return [
  {
    json: {
      text: `🚨 *New Issue:* <${$json["html_url"]}|#${$json["number"]}> – ${$json["title"]}`,
      username: "n8n Bot",
      icon_emoji: ":robot_face:",
    },
  },
];
Enter fullscreen mode Exit fullscreen mode

Why a Function node?

It lets you shape the data exactly how Slack expects it, without writing a separate micro‑service.

3.2.3. Hook up the Slack Node

  1. Add a Slack node → PostMessage.
  2. Connect it to the Function node.
  3. Authorize Slack (select workspace, channel, etc.).
  4. In the Message field, pick the Expression button and select {{$json["text"]}}.

3.2.4. Activate & Test

  • Click SaveActivate (toggle in the top‑right).
  • Open a new issue in the GitHub repo; you should see a ping in Slack within seconds.

3.3. Export the workflow (JSON)

You can share the whole thing as a JSON file:

{
  "name": "GitHub Issue → Slack Alert",
  "nodes": [
    {
      "parameters": {
        "events": [
          {
            "event": "issues",
            "operation": "opened"
          }
        ],
        "repository": "myorg/my-awesome-repo"
      },
      "name": "GitHub Trigger",
      "type": "n8n-nodes-base.githubTrigger",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "functionCode": "// n8n Function node – transform GitHub payload into a Slack message\nreturn [{\n  json: {\n    text: `🚨 *New Issue:* <${$json[\"html_url\"]}|#${$json[\"number\"]}> – ${$json[\"title\"]}`,\n    username: \"n8n Bot\",\n    icon_emoji: \":robot_face:\",\n  },\n}];"
      },
      "name": "Format Message",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [500, 300]
    },
    {
      "parameters": {
        "channel": "C01ABCD2EFG",
        "text": "={{$json[\"text\"]}}",
        "username": "={{$json[\"username\"]}}",
        "icon_emoji": "={{$json[\"icon_emoji\"]}}"
      },
      "name": "Slack Notify",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [750, 300]
    }
  ],
  "connections": {
    "GitHub Trigger": {
      "main": [
        [
          {
            "node": "Format Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Message": {
      "main": [
        [
          {
            "node": "Slack Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Drop the JSON into Import → Workflow and you’re good to go.


4️⃣ Pro Tips & Tricks 🎯

  • Version control – Store exported JSON files in Git. Treat workflows like code!
  • Error handling – Add a Set node after any step to capture $node["<node>"].error and route it to a Telegram or Email alert.
  • Cron triggers – Want a nightly data sync? Use the Cron node instead of an external scheduler.
  • Custom nodes – If the built‑in list doesn’t have your API, create a JavaScript node or publish a reusable npm package (see the n8n docs).
  • Docker compose – For production, spin up n8n with a Postgres DB and Redis queue:
version: "3.8"
services:
  n8n:
    image: n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=supersecret
    depends_on:
      - postgres
  postgres:
    image: postgres:13
    environment:
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=supersecret
      - POSTGRES_DB=n8n
Enter fullscreen mode Exit fullscreen mode
  • Community recipes – Check out the n8n.io/workflows gallery. You’ll find ready‑made templates for everything from RSS → Notion to Stripe → Google Sheets.

5️⃣ Wrap‑Up & Call‑to‑Action

You now have a live n8n instance, a working workflow, and a toolbox of tricks to keep building more complex automations. Remember:

  1. Treat workflows as code – version, test, and review them.
  2. Leverage the visual canvas for quick prototyping, then sprinkle in JavaScript for the heavy lifting.
  3. Iterate fast – a tiny change (e.g., add a “priority” label filter) can turn a basic alert into a fully‑featured triage bot.

Got a quirky automation idea? 🎉 Drop a comment below, share your workflow JSON, or ask for help tweaking a node. Let’s build a community of n8n ninjas together!


References

Happy automating! 🚀

Top comments (0)