n8n Tutorial: How to Automate Workflows with Connectors and Practical Examples
Learn to use n8n for automating workflows with this complete tutorial. Discover how to install and create workflows.
Erlan Carreira
Software Engineer & Entrepreneur
If you are looking for a powerful tool to automate processes without having to write lines and lines of code, n8n is the ideal solution. This complete n8n tutorial will guide you from the basics to practical examples of automation, showing how to integrate applications like Google Sheets, Gmail, Slack, and REST APIs. Learn to create efficient workflows, save time, and reduce manual errors. Let's dive into the universe of low-code automation with n8n.
What is n8n?
n8n is an open-source workflow automation platform that allows you to connect different services and applications through a visual interface. Unlike tools like Zapier or Make, n8n offers greater flexibility, local automation (you can host it on your server), and does not have rigid task limits. With n8n, you can create complex integrations, manipulate data, trigger actions based on events, and much more, all visually and with the option to add custom JavaScript code when necessary.
How to install n8n
There are several ways to install n8n, depending on your preference and infrastructure. The main methods are:
Installation via npx
If you have Node.js installed, just run: npx n8n. This will start n8n in your terminal, usually accessible at http://localhost:5678. It's the quickest way for testing and local development.
Installation with Docker
For more controlled environments, Docker is recommended. Run: docker run -it --rm --name n8n -p 5678:5678 n8nio/n8n. You can mount volumes to persist data. This approach is ideal for production or to keep the environment isolated.
n8n.cloud
If you prefer not to manage servers, n8n offers a managed cloud version (n8n.cloud). Just create an account, choose a plan, and start using it immediately. It's the simplest option for those who don't want to deal with infrastructure.
Getting started with n8n
After installation, access the web interface. The layout is intuitive: a left sidebar with available nodes, a central area to build the workflow, and a right panel for configuration. Let's create your first workflow:
- Add a trigger node: Drag a "Webhook" node onto the screen. This node waits for HTTP requests to start the flow.
- Configure the Webhook: Choose a method (GET or POST) and define a path. Click "Execute Workflow" to activate the webhook.
- Test the trigger: Use a tool like Postman or curl to send a request to the generated address. You will see the data arrive in n8n.
- Add an action: Connect a "Set" node to modify the received data or an "HTTP Request" node to send data to another API.
- Finish: Connect a "NoOp" (no operation) node or another output node. Activate the workflow and see the automation in action.
This simple flow demonstrates how n8n processes incoming data and executes actions. From there, you can explore hundreds of available connectors.
Main nodes and connectors in n8n
n8n offers a vast library of native connectors. Here are some of the most useful:
- HTTP Request: Makes requests to REST APIs. Supports GET, POST, PUT, DELETE, and authentication (Basic, OAuth2, API Key, etc.).
- Webhook: Receives external HTTP requests. Ideal for integrations with services that send events (e.g., GitHub, Stripe).
- Google Sheets: Reads and writes data in Google Sheets. Supports operations like creating, updating, and deleting rows.
- Gmail: Sends and reads emails, manages labels, etc. Very useful for notification automations.
- Slack: Sends messages, creates channels, manages users. Perfect for alerts and internal communications.
- Telegram: Sends messages to Telegram bots. Great for personal notifications.
- Discord: Similar to Slack, for communities.
- Database: Connectors for MySQL, PostgreSQL, MongoDB, SQLite, among others.
- Development tools: GitHub, GitLab, Jira, Trello, Asana.
Additionally, you can use the Code node to write scripts in JavaScript, Python, or even execute shell commands. This infinitely expands the possibilities of automation.
Examples of automation with n8n
Let's look at two practical examples that show the power of the n8n tutorial.
Example 1: Google Sheets and Gmail Integration
Scenario: When a new row is added to a Google Sheets spreadsheet (e.g., captured lead), send a welcome email via Gmail.
- Trigger: Use the "Google Sheets" node in "Watch Rows" mode. Configure the spreadsheet and the specific sheet. This node triggers every time a new row is added.
- Processing: Connect a "Set" node to extract the data from the new row (name, email, etc.) and store it in variables.
- Action: Connect the "Gmail" node in "Send" mode. Fill in the recipient with the extracted email, subject, and body of the message (HTML can be used).
- Activate the workflow: Now, each new lead will automatically receive a personalized email.
Example 2: Slack Notification for New Commits on GitHub
Scenario: Whenever a commit is made in a specific GitHub repository, send a notification to a Slack channel.
- Trigger: Use the "Webhook" node and configure GitHub to send a POST to this webhook whenever there is a push. In GitHub, go to Settings > Webhooks and add the URL generated by n8n.
- Processing: The "Webhook" node will receive the payload from GitHub. Use a "Code" node to extract relevant information (author, commit message, repository).
- Formatting: Use a "Set" node to build the message in the JSON format expected by Slack.
- Action: Connect a "Slack" node in "Send Message" mode. Configure the channel and the message content.
- Activate the workflow: From now on, every time someone pushes to the repository, Slack will receive an instant notification.
- Name your nodes descriptively: Instead of "HTTP Request," use "Fetch data from Customer API." This makes maintenance easier.
- Use tags and colors: n8n allows you to color and group nodes. Organize visually to quickly understand the flow.
- Handle errors: Add "Error Trigger" nodes to capture failures and send notifications (e.g., email or Slack).
- Validate data: Use "IF" or "Switch" nodes to check conditions before proceeding. Avoid processing incorrect data.
- Keep versions of workflows: n8n automatically saves version history. Use this to revert changes if necessary.
- Security: Never store hardcoded credentials. Use n8n's credentials manager to store tokens securely.
- Document the flow: Add notes (using the "Note" node) explaining the purpose of each section. This helps other team members.
These examples illustrate how n8n can connect services in a simple and powerful way.
Best Practices for Using n8n
To ensure that your workflows are robust and easy to maintain, follow these recommendations:
Frequently Asked Questions (FAQ)
Is n8n free?
Yes, n8n is open-source (licensed under the Sustainable Use License). You can use the self-hosted version for free. The cloud version (n8n.cloud) offers paid plans with support and managed infrastructure.
Do I need to know programming to use n8n?
It is not mandatory. You can create complete workflows using only the visual interface and native connectors. However, basic knowledge of JavaScript or Python can help with more complex integrations using the Code node.
What are the limitations of n8n?
Compared to Zapier, n8n does not have such a vast library of ready-made connectors but covers the main tools. Additionally, being self-hosted means you need to manage the infrastructure unless you use the cloud.
Can I use n8n with custom REST APIs?
Yes, the HTTP Request node allows you to consume any REST API. You can configure headers, methods, body, and authentication. It's one of the most flexible features of n8n.
How to update n8n on Docker?
To update, download the latest image: docker pull n8nio/n8n, then recreate the container with the appropriate command, keeping the data volumes.
Does n8n support webhooks to receive data from any service?
Yes, the Webhook node generates a public (or internal) URL that can be used by any service to send data. It supports GET, POST, PUT, DELETE and receives payloads in JSON, XML, etc.
Conclusion
This n8n tutorial demonstrated how the tool can transform the way you automate daily tasks. From simple installation to creating complex workflows integrating Google Sheets, Gmail, Slack, and GitHub, n8n provides freedom and control over your automations. With the best practices and practical examples presented, you are ready to explore even more possibilities. Remember to consult the official documentation and the active community for questions and to share your flows. Automate with confidence!
Erlan Carreira
Software Engineer & Entrepreneur
Specialist in software development, automation, and SaaS. I write about technology, digital business, AI, and engineering practices for teams committed to execution excellence.