{
  "name": "n8n for Beginners: Free Local Setup Step by Step",
  "nodes": [
    {
      "id": "a1",
      "name": "Question Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        300
      ],
      "parameters": {
        "formTitle": "Ask the Local AI",
        "formDescription": "Type a question. A free AI model running on this server will answer it right here on this page.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Question",
              "fieldName": "Question",
              "fieldType": "textarea",
              "placeholder": "e.g. Explain what an automation trigger is in two sentences",
              "requiredField": true
            }
          ]
        },
        "options": {
          "path": "ask-local-ai",
          "buttonLabel": "Ask the AI",
          "appendAttribution": false
        }
      }
    },
    {
      "id": "a2",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        300
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "prompt",
              "type": "string",
              "value": "={{ $json.Question }}"
            },
            {
              "id": "f2",
              "name": "submittedAt",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "a3",
      "name": "Answer with Local AI",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        520,
        300
      ],
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.prompt }}",
        "messages": {
          "messageValues": [
            {
              "message": "You are a friendly assistant for beginners. Answer clearly in plain language in under 120 words."
            }
          ]
        }
      }
    },
    {
      "id": "a4",
      "name": "Ollama llama3.2 3B",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        520,
        520
      ],
      "parameters": {
        "model": "llama3.2:3b",
        "options": {
          "temperature": 0.4,
          "numCtx": 4096,
          "keepAlive": "10m"
        }
      }
    },
    {
      "id": "a5",
      "name": "Create Answers Table",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.7,
      "executeOnce": true,
      "alwaysOutputData": true,
      "position": [
        820,
        300
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "CREATE TABLE IF NOT EXISTS form_answers (\n  id serial PRIMARY KEY,\n  question text NOT NULL,\n  reply text,\n  submitted_at timestamptz\n);"
      }
    },
    {
      "id": "a6",
      "name": "Save Question and Reply",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.7,
      "executeOnce": true,
      "position": [
        1080,
        300
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO form_answers (question, reply, submitted_at)\nVALUES ($1, $2, $3)\nRETURNING id, submitted_at;",
        "options": {
          "queryReplacement": "={{ [ $('Edit Fields').first().json.prompt, $('Answer with Local AI').first().json.text, $('Edit Fields').first().json.submittedAt ] }}"
        }
      }
    },
    {
      "id": "a7",
      "name": "Show Reply on Form",
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.5,
      "position": [
        1340,
        300
      ],
      "parameters": {
        "operation": "completion",
        "completionTitle": "Here is your answer",
        "completionMessage": "={{ $('Answer with Local AI').first().json.text }}",
        "options": {}
      }
    },
    {
      "id": "s1",
      "name": "1. Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        200
      ],
      "parameters": {
        "content": "## 1. Trigger\nA form with one question field",
        "width": 240,
        "height": 260,
        "color": 4
      }
    },
    {
      "id": "s2",
      "name": "2. Prepare data",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        220,
        200
      ],
      "parameters": {
        "content": "## 2. Prepare data\nRename and select the fields",
        "width": 240,
        "height": 260,
        "color": 5
      }
    },
    {
      "id": "s3",
      "name": "3. Local AI",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        480,
        200
      ],
      "parameters": {
        "content": "## 3. Local AI\nLLM Chain + Ollama on this server",
        "width": 240,
        "height": 460,
        "color": 6
      }
    },
    {
      "id": "s4",
      "name": "4. Save",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        780,
        200
      ],
      "parameters": {
        "content": "## 4. Save\nStore question and reply in Postgres",
        "width": 540,
        "height": 260,
        "color": 7
      }
    },
    {
      "id": "s5",
      "name": "5. Respond",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1300,
        200
      ],
      "parameters": {
        "content": "## 5. Respond\nShow the reply on the same form page",
        "width": 240,
        "height": 260,
        "color": 3
      }
    }
  ],
  "connections": {
    "Question Form": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Answer with Local AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama llama3.2 3B": {
      "ai_languageModel": [
        [
          {
            "node": "Answer with Local AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Answer with Local AI": {
      "main": [
        [
          {
            "node": "Create Answers Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Answers Table": {
      "main": [
        [
          {
            "node": "Save Question and Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Question and Reply": {
      "main": [
        [
          {
            "node": "Show Reply on Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}