Host n8n yourself with Docker and run an AI workflow on your own server
Start n8n Community Edition with the official Docker command, then build a Chat Trigger to Basic LLM Chain workflow on your own server.
Start n8n Community Edition with the official Docker command, then build a Chat Trigger to Basic LLM Chain workflow on your own server.
n8n Community Edition running in Docker on your own machine or server, with a chat workflow (Chat Trigger, Basic LLM Chain, chat model) that you can message from the editor.
Europe/Berlin.Where things run: the workflow and its data run on your server. The chat model runs wherever its credential points. With an OpenAI credential, each prompt is sent to OpenAI and needs that provider's key. n8n also has an Ollama Chat Model node whose credential Base URL can point at a local Ollama for a fully self-hosted setup: see https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatollama/common-issues.md.
Create a Docker volume for n8n's persistent data.
docker volume create n8n_dataStart n8n. Replace both <YOUR_TIMEZONE> placeholders with your timezone. This downloads the n8nio/n8n image, publishes port 5678 and mounts the volume at /home/node/.n8n.
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \
-e TZ="<YOUR_TIMEZONE>" \
-e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
-e N8N_RUNNERS_ENABLED=true \
-v n8n_data:/home/node/.n8n \
n8nio/n8nThe \ line breaks are for bash-style shells. In PowerShell, put the whole command on one line without them. Leave this terminal open: n8n runs in it.
Open http://localhost:5678 in a browser and complete the first-run setup that n8n shows. Without a license key, n8n runs as the free Community Edition.
Select Create Workflow (or Start from Scratch).
Select Add first step, search for Chat Trigger and select it. It appears on the canvas as When chat message received. Leave Make Chat Publicly Available off.
Select the Add node connector on the Chat Trigger, search for Basic LLM Chain and select it. Keep Prompt set to Take from previous node automatically (shown as Connected Chat Trigger Node in some versions). This reads the chatInput field that the Chat Trigger outputs.
On the Basic LLM Chain node, select the chat model connector below the node, search for OpenAI Chat Model and select it.
In the OpenAI Chat Model node, open the credential dropdown and select Create new credential. Paste your key into API Key. Leave Organization ID blank unless you belong to more than one OpenAI organization. Save the credential.
In Model, pick a model. n8n loads the list from your OpenAI account.
Select Open chat at the bottom of the canvas (the button is labelled Chat in some versions), type Say hello in five words and send it.
You should see a reply from the model in the chat panel, and the Chat Trigger, Basic LLM Chain and OpenAI Chat Model nodes marked as executed on the canvas. Every message you send runs the workflow once.
If you see a credential or model error, reopen the OpenAI Chat Model node and check the API Key and Model.
To check persistence: stop the container with Ctrl+C, run the docker run command from step 2 again, and reload http://localhost:5678. Your workflow and credential are still there because they are stored in the n8n_data volume.
Want tools and memory? Replace Basic LLM Chain with the AI Agent node. The n8n docs say an AI Agent needs a chat model and at least one tool sub-node: https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/.