How to Self Host n8n AI Agents for FREE - n8n + Ollama + Docker + Ngrok
Table of Contents
Introduction
This tutorial will guide you through the process of self-hosting n8n AI agents for free using Docker, Ngrok, and Ollama. By following these steps, you'll be able to automate tasks with AI, enhancing your productivity and business operations.
Step 1: Set Up Docker
-
Install Docker
- Visit the Docker website to download and install Docker Desktop for your operating system.
- Follow the installation instructions provided on the site.
-
Verify Docker Installation
- Open your terminal (Command Prompt, PowerShell, or Terminal).
- Run the following command to check if Docker is installed correctly:
docker --version
-
Pull n8n Docker Image
- In your terminal, execute the following command to pull the n8n image:
docker pull n8nio/n8n
- In your terminal, execute the following command to pull the n8n image:
-
Run n8n Container
- Use this command to start an n8n container:
docker run -d --name n8n -p 5678:5678 n8nio/n8n - This command runs n8n in detached mode and maps port 5678 to your local machine.
- Use this command to start an n8n container:
Step 2: Set Up Ngrok
-
Sign Up for Ngrok
- Go to the Ngrok website and sign up for a free account.
-
Download Ngrok
- After signing up, download Ngrok for your operating system.
-
Install Ngrok
- Follow the installation instructions provided on the Ngrok website to set it up on your system.
-
Connect Ngrok to Your Account
- In your terminal, run the command to authenticate Ngrok with your authtoken:
ngrok authtoken YOUR_AUTHTOKEN - Replace
YOUR_AUTHTOKENwith the token provided on your Ngrok dashboard.
- In your terminal, run the command to authenticate Ngrok with your authtoken:
-
Expose Your n8n Instance
- Start Ngrok to expose your n8n instance:
ngrok http 5678 - Ngrok will provide you with a public URL that tunnels to your local n8n instance.
- Start Ngrok to expose your n8n instance:
Step 3: Install and Configure Ollama
-
Visit Ollama Website
- Navigate to the Ollama website to download and install the Ollama CLI.
-
Run Ollama
- Open your terminal and run the following command to start Ollama:
ollama run YOUR_MODEL_NAME - Replace
YOUR_MODEL_NAMEwith the specific AI model you want to use.
- Open your terminal and run the following command to start Ollama:
-
Integrate with n8n
- Set up your n8n workflows to utilize the Ollama model by calling it through HTTP requests.
Step 4: Create Workflows in n8n
-
Access n8n Interface
- Open your browser and navigate to the Ngrok URL provided earlier (e.g.,
http://12345678.ngrok.io).
- Open your browser and navigate to the Ngrok URL provided earlier (e.g.,
-
Create a New Workflow
- Click on "New" to start a new workflow in the n8n interface.
-
Add Nodes
- Use the various nodes available in n8n to create automations. For example, you can add:
- HTTP Request node to call the Ollama model.
- Trigger nodes based on different events.
- Use the various nodes available in n8n to create automations. For example, you can add:
-
Test Your Workflow
- Once your workflow is set up, execute it to ensure everything is functioning as expected.
Conclusion
By following these steps, you have successfully set up n8n AI agents using Docker, Ngrok, and Ollama. You can now create powerful automations that leverage AI capabilities. Consider exploring more complex workflows and integrating additional functionalities as you become more comfortable with the tools. Happy automating!