Introduction
Hi :D
This week I'll start to work with n8n and automations.
The idea of this week is to understand all the "theoretical" part of n8n, and next week build something fun.
I mean, next week we will build an automation. It's not like fun fun, but you get it. Also, it will be great to have it, especially if you are looking for your next role :D
Topics
- What is n8n?
- Fundamental blocks
- Triggers
- Nodes
- Connections
- Types of nodes
- How to build a robust flow
What is n8n?
It's a workflow automation tool.
The main idea is to connect services between them to automate things, without the need to write all the code (and the server) to orchestrate the actions.
You build the workflow in a visual editor: you drag nodes, connect them with arrows, and each node does one thing. For example: "when I receive an email, send it to OpenAI to classify it, and save the result in Google Sheets".
Some things that I like about n8n:
- It has 400+ integrations (Gmail, Slack, Google Sheets, OpenAI, Airtable...), and if a service doesn't have a node, you can call its API with an HTTP request.
- You can write code (JavaScript or Python) when the nodes are not enough. So it's "low-code", not "no-code".
- You can self-host it for free, or pay for n8n Cloud and they host it for you.
- It has AI nodes, like the AI Agent node, to use LLMs inside your workflows.
Fundamental blocks
Triggers
It's the node which starts the workflow.
It could be:
- A webhook
- A cron job
- A service event
Nodes
It's each step in the workflow. They are the equivalent of a function or an API call.
Connections
They are the arrows between the nodes. The output of a node is the input of the next one connected by that arrow. If a node fails, you can define a new alternative flow (known as fallback).
Note: the data travels between nodes as a list of items (each item is like a JSON object). Most nodes run once for each item. So if a trigger returns 10 emails, the next node will process 10 items.
Types of nodes
We have 4 types of nodes.
1. Triggers
They start the workflow. A workflow needs at least one trigger (it can have more than one), and if we don't have a trigger, the workflow will never start.
Eg: a manual trigger, a Gmail trigger, a schedule trigger.
2. Action nodes
These are the nodes which do something with the data. It's where the magic happens.
It could be:
- an external service: connect to services like OpenAI, Telegram, Gmail, Google Sheets, Airtable.
- an HTTP request: when the service doesn't have a node, we can connect to it directly with its API.
3. Flow control nodes
These are the nodes that control the path that the data follows. They don't call APIs or services, they just decide what happens after the action.
Eg:
- If => if it matches a condition, it chooses a specific path
- Switch => it's like an If but with several paths
- Merge => it combines the data from two branches into one
4. Data transformation nodes
They modify the data.
Eg:
- Set (Edit Fields): rename or simplify the fields
- Split Out: takes a list inside one item and separates it into several items
- Code: you can write pure code
How to build a robust flow
When we are working on a workflow, we will have the happy path, but when we want to go to production we need to create a robust flow. For these cases, we have to think about the not so happy path.
For that reason we need to implement:
- Error handling: what we want to do when a node fails. In the node settings you have Retry On Fail (try again X times before failing) and On Error, where you choose if the workflow stops, continues, or continues using an error output.
- Fallback: if it fails, we need to think of an alternative flow. That's the error output: a second arrow that only runs when the node fails.
- Alerts: we need to know when something goes wrong. n8n has an Error Workflow: a separate workflow that starts with an Error Trigger node every time another workflow fails, so you can send yourself a message on Slack or an email.
Wrapping up
I know that it could be a lot to understand just in one post, but it will be easier if we see it in practice.
So see you next week :D



