How to self-host n8n and build your first AI workflow

Run n8n locally with Docker, connect an AI model and build a workflow that summarizes incoming text and posts the result.

n8n is a workflow automation tool you can run on your own machine or server. Like other automation platforms, it connects apps through triggers and actions, but because you host it, your workflow data stays on infrastructure you control and you are not limited by per-task pricing. It also has built-in nodes for AI models, which makes it a practical way to add language model steps to everyday processes.

In this tutorial you will run n8n with Docker on your own computer, add credentials for an AI model and build a small workflow: a webhook receives a customer message, an AI node summarizes it and classifies its urgency, and the result is returned as JSON.

How it works

An n8n workflow is a graph of nodes. Each node receives items, does something with them and passes items on. There are three kinds you will use:

  • Trigger nodes start a workflow, for example a webhook, a schedule or a new email.
  • Action nodes call an app or service, such as an AI model or a spreadsheet.
  • Logic nodes transform or route data, for example an If node or a Set node.

Data moves between nodes as JSON. You reference values from earlier nodes with expressions written in double curly braces, such as {{ $json.message }}.

Credentials, such as API keys, are stored separately from workflows and encrypted. You add them once and reuse them in any node.

Why Docker

Docker packages n8n with everything it needs, so the same setup runs on a laptop or a server. A named volume keeps your workflows and credentials when the container is recreated or updated. For a first install, one command is enough:

docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

The first command creates a volume for persistent data. The second starts n8n, maps port 5678 to your machine and mounts the volume where n8n stores its files.

Before you start

This setup is for learning and local use. Running n8n on a public server needs more: HTTPS through a reverse proxy, a strong owner password, regular updates and backups of the data volume. If you later expose webhooks to the internet, anyone who knows the URL can call them, so add authentication to production webhooks.

AI providers charge per use, and a workflow in a loop can make many calls quickly. Set a spending limit in your provider account before testing.