What is n8n: Build AI Workflows with n8n
This guide discusses how to create AI workflows in n8n.
What you’ll learn:
- Basics of n8n workflows.
- How to install and set up n8n on Windows, macOS, and Linux machines.
- How to create AI workflows using n8n.
Let’s start with the basics of n8n and n8n workflow.
What is n8n?
N8n is a workflow automation tool that lets us create multi-step AI agents and automate workflows using visual tools. It is a no-code open-source tool that we can use in self-hosted and in-cloud setups on any operating system using Node.js or Docker.
N8n allows us to integrate tools like Slack, Microsoft Teams, Spreadsheets, forms, and databases to create workflows and AI agents. Despite being a visual and no-code tool, n8n also allows us to include JavaScript or Python functions in the workflows and add libraries from Node package manager(npm) or Python, which makes it a great workflow automation tool for people who code and who don’t alike.
What is an n8n workflow?
An n8n workflow is an automated sequence of tasks created using n8n. A workflow consists of multiple nodes.
- Trigger: A trigger node initiates an n8n workflow execution based on a specific event. The trigger node listens for events like scheduled time or incoming webhooks. Webhook triggers start a workflow after receiving an HTTP request. For example, a webhook trigger can accept a POST request from a form to trigger the n8n workflow.
- Nodes: Nodes in an n8n workflow perform individual actions like fetching data from an API, sending an email or a Slack message, and processing data.
The n8n workflow starts when the trigger node is executed due to an event. After this, all the nodes in the given workflow execute in a specified order to process data and produce the output. For example, we want to create an automated workflow that analyzes reviews posted by the learners on the Codecademy website and sends the review summary to a Slack channel. For this, the n8n workflow will look as follows:
Input Form (Trigger node that starts the workflow after receiving a review) --> Summarizer Node (To summarize the review) --> Slack node (To send the review summary to a Slack channel)
Let’s download n8n and build an n8n workflow to understand how it works.
Download and setup n8n locally
We need Node.js and npm to install and run n8n on our machine. Hence, we will first install these modules on our machine.
Download Node.js and npm
For Windows, you can install Node.js and npm from the Node.js downloads page.
To download Node.js on macOS, you can execute the following command in the command-line terminal, which will install Node.js and npm together on your machine:
brew install node
To install Node.js in Linux, we will first install npm using apt:
sudo apt-get install npm
Next, we will install Node Version Manager (nvm), which helps us install, manage, and switch between multiple versions of Node.js. For this, you can execute the following command in the command-line terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
After installing nvm, close the current terminal and start a new one. To run n8n, we need Node.js version 16 or greater. Hence, we will install Node.js version 22.x using the following command:
nvm install 22
Having Node.js and npm installed, we will install n8n using npm.
Install n8n
In Windows and macOS, you can install n8n by executing the following command in the command-line terminal:
npm install -g n8n
On Linux systems, you might need to install n8n in superuser mode using the following command:
sudo npm install -g n8n
After installing npm, Node.js, and n8n, we can check their versions using the npm -v, node -v, and n8n -v commands.
Run n8n
To start n8n, we will execute the n8n command in the command-line terminal, as shown in the following image:
If you want to run n8n in the background on Linux and macOS systems, you can use the nohup command:
nohup n8n &
By default, n8n starts on port number 5678, and you can go to http://localhost:5678 to access the n8n editor. When we open n8n for the first time, it asks to set up the owner account, as shown in the following image:
To proceed, you can fill in all the details and click on the Next button. Then, you will get a personalization screen and a screen offering paid features, where you can access some of the paid features for free. Once you fill in all the details and move ahead from those screens, you will get the n8n home screen, as shown in the following image:
So, we have successfully set up n8n on our local system. If you want to access n8n online, you can register for a 14-day trial.
As n8n is a workflow automation tool, we will create an automated review summarization workflow to see how n8n works. Let’s discuss the different components of building an n8n workflow that summarizes a review and sends it as a message to a Slack channel.
N8n components for building the AI workflow
The n8n workflow for review summarization will have the following components:
- Trigger node: We will use an n8n Form trigger to get the user’s review. You can also initiate the trigger node using other tools like Google Forms, Jotform, Webflow, or Typeform.
- Summarization chain node: The summarization chain node in n8n is used to generate a summary from a text using a large language model(LLM). You can define the output length and prompt for the summarization in the summarization chain node.
- LLM: The summarization chain node needs an LLM to generate the summary. We will use the Gemini API for LLM access.
- Slack node: The Slack node in n8n performs Slack-specific operations like sending messages, deleting messages, creating channels, etc. We will use the Slack node to send the review summary to a Slack channel.
We need to add configurations with API keys to use the LLM and the Slack node. Let’s discuss how to configure the LLM and Slack APIs in n8n.
Configure LLM and Slack APIs in n8n
We will use the Gemini API to access LLMs for summarization. To do this, you must get a Gemini API key. If you want to use ChatGPT models, create an OpenAI API key.
We also need a Slack app with a Slack bot to send messages. If you don’t have a Slack app for your workspace, you can create one using the Slack app quickstart.
After getting the Gemini API key and the Slack token, let’s configure Gemini and Slack in n8n.
Configure Gemini AI model in n8n
To configure Gemini, we will first go to the credentials tab on the n8n homepage. As we don’t have any credentials configured yet, it will look as follows:
Click on the Add first credential button. This gives us a pop-up to search for and configure any service.
Search for “Gemini” in the pop-up search bar.
Select the Google Gemini(PaLM) API option in the search results.
Next, click on the Continue button, which gives the following Gemini credential screen:
Paste your Gemini API key in the API Key field and click on the Save button.
Once we hit the Save button, n8n tests the credentials and notifies us in case of successful connection. After successful setup, click on theX button on the top-right of the credential popup. This takes us to the credentials tab on the n8n homepage:
As you can see, we have successfully configured the Gemini API. If you are working with models from another LLM provider, you can search for the API name in the credentials search bar and set up the respective APIs. Now, let’s configure the Slack API to help us send messages to Slack.
Configure Slack in n8n
To configure Slack, click on the + button on the top-left corner of the screen, beside the n8n logo. It gives us a menu as shown in the following image:
Click on Credential, which gives us the popup to create a new credential. Search for “Slack” in the pop-up search bar.
Select Slack API from the search results and hit Continue.
Next, we get the Slack config screen. You can paste the Slack access token in the Access Token field.
Once you paste the Slack token and click on the Save button, n8n tests the token and notifies us after successful configuration.
After this, you can click on the X button on the top-right of the configuration pop-up, which takes you to the n8n home screen.
You can see that Slack and Gemini API are successfully configured here.
Now that we have successfully set up the credentials, let’s create the n8n AI workflow to summarize reviews using Gemini and send them as Slack messages.
Create an n8n workflow step by step
To create the AI workflow for summarizing reviews and sending messages to Slack using n8n, we will use the following steps:
- First, we will create a trigger node that starts the workflow. We will use n8n forms for this task.
- Next, we will create an AI summarization node using Gemini AI.
- Finally, we will create a Slack node to send messages.
Let’s discuss each step individually.
Create a form to take review inputs
To create a new n8n workflow, click on the + icon on the top left of the screen and then click on the Workflow button. Then, we get the following screen:
You can rename the workflow by clicking on and editing the workflow name My workflow at the top of the screen. To add the trigger node, click on the + icon in the center of the empty workflow. This gives us the following search menu:
Search for “form” in the search menu. You will get different form options.
Click on n8n Form. Then, we get a new list with On new n8n Form event label:
Click on the On new n8n Form event button, which opens the form editor, as shown in the following image:
You can fill in all the details in the form and create different fields.
After filling in the form details and creating different fields, click on the Back to canvas button on the top left of the form popup. This takes us to the n8n workflow editor.
As you can see, we have successfully added the form to the n8n workflow. It takes the name, email, and review as its inputs. You can also see an Execute workflow button on the screen. If you click on the Execute workflow button, a form will open in a new browser window where you can enter the details and the review. However, let’s first add a summarizer to the workflow that will summarize the review. Then, we will execute the workflow and observe the outputs.
Add a summarization node using Gemini LLM
To add the summarization node, click on the + icon on the right of the form node, which gives us a search menu.
In the search menu, search for “Summarization”, which gives us the Summarization Chain option in the search results.
Click on the Summarization Chain icon. This opens the summarization chain details in a pop-up. In the details, you can specify the length of the generated summary and the prompt given to the LLM for summarization.
After specifying the different details for the summarization chain, click on the Back to canvas button on the top left of the popup. This takes us to the workflow editor.
In this image, you can see that the summarization chain shows an error mark. This is because we haven’t yet added an LLM to the summarizer, which is important for the summarization chain to work.
Click on the + icon below the Model* icon in the summarization chain to attach the LLM to the node, which gives us a search menu with different LLM names.
Search for “Gemini” in the search menu. This gives us “Google Gemini Chat Model” in the search results.
Click on the Google Gemini Chat Model icon, which opens the model details page.
As we have configured Gemini in the credentials, we don’t need to perform any action here. Click on the Back to canvas button on the top-left of the popup to go back to the n8n workflow editor.
As you can see, the summarization node is configured without error. Let’s execute the workflow using the Execute workflow button. This will open the form in a new browser window that takes reviews as its input:
We will submit the following review in the form.
I've had a great experience learning with Codecademy. The platform is beginner-friendly and does a fantastic job of breaking down complex coding concepts into simple, interactive lessons. I especially love the hands-on approach—being able to code directly in the browser and get instant feedback makes learning much more engaging.I started with their Python course and eventually moved to web development and SQL. The career paths are well-structured and guide you through a logical progression of skills. The Pro subscription is worth it if you're serious about learning, as it unlocks real-world projects, quizzes, and certificates.One of the things I appreciate most is that Codecademy doesn't just teach syntax, but also explains how and when to use certain tools in real scenarios. The community forums and support are helpful too, especially when you're stuck.Overall, Codecademy is an excellent resource for anyone who wants to start coding or level up their skills at their own pace. Highly recommended!
After submitting the form, we get a “Workflow executed successfully” pop-up, which means that the summarization chain has successfully executed after submitting the form.
To have a look at the output of the summarization chain, click on the ^ button on the right of the Clear execution button on the bottom left of the screen to get the output panel.
In the output panel, you can see the summary of the review we submitted in the form.
Now that we have the summary generated, let’s add a Slack node in the current n8n workflow to send the review summary to a Slack channel.
Add Slack message functionality in the n8n workflow
To add a Slack node to the n8n workflow, click on the + icon on the right side of the summarization chain node. It gives us the search menu on the right side of the screen. Search “slack” in the search menu, which provides us with the following search results.
Click on the Slack icon in the search results. It gives another search menu for different Slack operations.
Search for “send” in the menu, which gives us the following search results:
Click on the Send a message icon, which gives us the following details page:
On the Slack node details page, fill in all the details, such as whether you want to send the message to an individual or a channel and the Slack channel ID.
We will send the output of the summarizer node as a Slack message. To include the output of the summarization node in the Slack message, click on the Expression icon above the Message Text textbox.
Next, drag the text icon of the Summarization chain output to the textbox, which makes the textbox look as follows:
After this, click on the Execute button at the top of the popup. This will send the message output to Slack, and we get the following output screen.
Now, return to the n8n workflow editor by clicking the Back to canvas button. Here, you can see that all the nodes have a green tick mark showing that they have executed successfully.
If you go to the Slack channel, you can see the received message:
Instead of the Slack message, you can configure emails and other notifications to get the output summary. You can also configure the n8n workflow to store the generated summary in a CSV file or Google Sheets.
Now that we have successfully set up the AI text summarization workflow using n8n, you can click on the Execute workflow button to run the workflow manually. If you have configured it to receive inputs from other form apps, the workflow will execute if it gets a form entry.
Save and execute the n8n review summarization workflow
The final AI summarization workflow looks as follows:
Every time we click the Execute workflow button, we get a new form as shown below:
You can fill out the details and submit the form. The n8n workflow will automatically generate a summary of the form input and send it as a Slack message, which you can see in the Slack channel.
To save the n8n workflow, click the Save button at the top of the workflow editor. You can also use Ctrl + S to save the workflow.
Once you exit the n8n workflow editor and come to the homepage, the workflow is listed in the Workflows tab.
You can turn the n8n workflow on and off using the toggle on the right side of the workflow. You can also archive an n8n workflow by clicking on the ⋮ icon on the right of the workflow and selecting appropriate options. If you want to add new nodes or remove any nodes from a saved n8n workflow, you can click on the workflow, and it will open in the editor. Then, you can modify the n8n workflow as you want.
Having discussed how to set up n8n and build AI workflows, let’s look at some of its features that make it a great tool for creating and automating workflows.
Features of n8n
The following are some of the n8n features that make it a great automation tool:
- Open-source and self-hosted: N8n is fully open-source, and you can host it on your own servers to automate workflows, ensuring full data control and privacy. The self-hosted versions also provide some paid features for free if you register using your email. If you don’t want to self-host N8n, it also provides a paid version with cloud hosting.
- Visual workflow editor: N8n provides a drag-and-drop, node-based editor for creating and automating AI workflows. This helps us build and automate complex workflows easily without writing code.
- More than 500 integrated apps: N8n provides specialized nodes to integrate most LLM providers, email services, Slack, GitHub, Notion, MySQL, etc. If a service isn’t natively supported in n8n, you can integrate them in your workflows by making API calls using the HTTP Request node.
- Built-in user and credentials management: N8n allows us to securely manage API keys and tokens. It comes with OAuth2 support out of the box, and we can also use JSON Web Tokens(JWT) and Single Sign On(SSO) for user and credentials management.
- Code and no-code features: N8n allows us to use JavaScript and Python code to implement advanced logic in the workflows. This gives us the flexibility to use built-in nodes for common tasks and Python or JavaScript code for specific tasks. Having both code and no-code tools makes n8n suitable for coders and non-coders.
Conclusion
N8n helps us build workflows by integrating over five hundred apps with minimal coding. Whether you’re automating internal processes, integrating third-party tools, or experimenting with AI-driven features, n8n offers the control and customization needed to scale efficiently. With an open-source foundation and an intuitive interface, it’s a great choice if you are looking to build and automate AI workflows.
In this article, we discussed how to install n8n and build an AI summarizer using the Gemini API. To learn more about automation, you can go through the IT Automation with Generative AI skill path that discusses AI fundamentals, SRE practices, ethical considerations, server monitoring, and automation system integration. You might also like this Automated Testing with Selenium skill path that discusses test implementation, web driver framework, mobile testing, and automation techniques for software development.
Frequently asked questions
1. Does n8n require coding?
No. N8n doesn’t require coding; you can easily build AI workflows using visual tools without coding.
2. How to start an n8n workflow?
You can start an n8n workflow using the trigger node. If you have set a webhook trigger that gets triggered on HTTP requests, you can send a request to start the n8n workflow. If you have used a schedule as a trigger, the workflow will be triggered at the scheduled time. Manually, you can start an n8n workflow using the Execute Workflow button in the n8n workflow editor.
3. What language does n8n use?
N8n is built using TypeScript and JavaScript and runs on Node.js. However, you don’t need any programming language to create n8n workflows. You can build most workflows by visually connecting different types of nodes.
4. Is n8n an ETL?
N8n is not an ETL tool. However, you can use it as an ETL tool by creating workflows to extract data from APIs and process it, which works well for light to moderate ETL pipelines. N8n might not be suitable for large-scale data processing.
5. Is n8n totally free?
Yes, the self-hosted version of n8n is open-sourced and completely free. However, we need to pay to use the n8n cloud version.
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full teamRelated articles
- Article
Build a Blog Research and Writer n8n Workflow: Complete Guide
Learn how to build a blog research and writer n8n workflow that automatically researches topics and creates high-quality articles. - Article
How to Set Up n8n Google Sheets Integration
Learn how to integrate Google Sheets with n8n. Set up OAuth, build webhooks, and automate your spreadsheets. - Article
How to Run n8n with Docker (Beginner's Guide)
Learn to run n8n with Docker Compose. Step-by-step guide for self-hosted n8n setup, authentication, and workflow automation
Learn more on Codecademy
- Get an introduction to Node.js—a JavaScript runtime environment typically used to build back-end apps.
- Beginner Friendly.3 hours
- Learn about the different components of a web application's back-end and explore the Node.js JavaScript runtime environment.
- Intermediate.5 hours
- Start your programming journey with an introduction to the world of code and basic concepts.
- Includes 5 Courses
- With Certificate
- Beginner Friendly.4 hours