{
  "name": "Guide students with an AI tutor chatbot using RAG, intent classification and GPT-4o-mini",
  "nodes": [
    {
      "id": "bfecf1c3-4941-4ce3-b2be-a6af427a8a0f",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        336
      ],
      "parameters": {
        "width": 460,
        "height": 904,
        "content": "### AI Tutor – Nathan (Interactive Learning Chatbot)\n\nThis workflow powers **Nathan**, an AI-driven educational tutor chatbot that guides users through personalised, topic-based learning sessions usin"
      }
    },
    {
      "id": "45ea014a-1614-436d-a7fd-225c398d0ab4",
      "name": "Section – Receive & Classify Intent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        464
      ],
      "parameters": {
        "width": 580,
        "height": 740,
        "content": "## 1. Receive & Classify Intent\nThe chat trigger receives the user message. **DeepSeek** classifies it into one of five intents — *greeting, topic, answer, question, or random* — using a sliding-windo"
      }
    },
    {
      "id": "ad0c4fae-0b32-4437-bc04-4cab37259de1",
      "name": "Section – Fetch & Merge Prompt",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        464
      ],
      "parameters": {
        "width": 760,
        "height": 380,
        "content": "## 2. Fetch & Merge System Prompt\nThe classified intent looks up the matching system prompt from the Google Sheets prompt library. The prompt and the original chat input are then merged and aggregated"
      }
    },
    {
      "id": "125205f3-a73f-4110-af3e-c24996a22f1c",
      "name": "Section – AI Teacher Agent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2624,
        464
      ],
      "parameters": {
        "width": 520,
        "height": 840,
        "content": "## 3. AI Teacher Agent (RAG)\n**GPT-4o-mini** generates a pedagogically appropriate response using the fetched system prompt, full session memory, and relevant content retrieved from the Pinecone book "
      }
    },
    {
      "id": "c696b2f2-0a3a-4e87-aa91-d6c2eb3ddfdc",
      "name": "Section – Log & Return Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3120,
        464
      ],
      "parameters": {
        "width": 540,
        "height": 380,
        "content": "## 4. Log & Return Response\nAppends the session ID, user message, and AI response to the **Preservation** sheet in Google Sheets. The final output is then formatted and returned to the chat interface."
      }
    },
    {
      "id": "308eea9c-51c3-4934-92bb-ca9e1dc7fe1d",
      "name": "DeepSeek LLM",
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "position": [
        1296,
        1152
      ]
    },
    {
      "id": "b9b7afa7-4a54-49df-8647-bf6f00dadeeb",
      "name": "Intent Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1296,
        784
      ]
    },
    {
      "id": "6c78f721-2f4f-4a08-8b9f-7c0b45d07615",
      "name": "OpenAI Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        2944,
        1264
      ]
    },
    {
      "id": "300621f3-15e7-4f23-9507-965ee0dfa1b5",
      "name": "GPT-4o-mini LLM",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2672,
        1088
      ]
    },
    {
      "id": "d5ce0842-aed3-4193-95b2-211bd30a3c75",
      "name": "Teacher Session Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2784,
        1280
      ]
    },
    {
      "id": "0308dc90-cb35-4b86-89c9-0b8458cd6159",
      "name": "Format Response Output",
      "type": "n8n-nodes-base.set",
      "position": [
        3504,
        832
      ]
    },
    {
      "id": "a761107b-727b-4aff-835d-317c25f69171",
      "name": "AI Teacher Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2672,
        832
      ]
    },
    {
      "id": "4cb84446-5217-481b-817f-ea04cb169c75",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1008,
        624
      ]
    },
    {
      "id": "f0e90733-8e14-4406-98ec-e04a7fb94bcf",
      "name": "Aggregate Fields",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2448,
        640
      ]
    },
    {
      "id": "78a9bcc5-fbad-4033-a09f-ff2d7582707d",
      "name": "Merge Input and Prompt",
      "type": "n8n-nodes-base.merge",
      "position": [
        2160,
        640
      ]
    },
    {
      "id": "0a896dec-5ed3-4108-85ba-0b91e79c5e42",
      "name": "Classifier Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1392,
        1024
      ]
    },
    {
      "id": "6b044d02-ed89-4e5a-ae23-f3df1bf1e82e",
      "name": "Fetch System Prompt",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1872,
        784
      ]
    },
    {
      "id": "2eedf477-8e24-4346-9f37-6083f91c0be0",
      "name": "Log Q&A to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3168,
        832
      ]
    },
    {
      "id": "232a6427-0b3b-40a9-bd91-5f138bf49c1b",
      "name": "Book Knowledge Base",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        2944,
        1056
      ]
    }
  ],
  "connections": {
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "Merge Input and Prompt",
            "type": "main",
            "index": 0
          },
          {
            "node": "Intent Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepSeek LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o-mini LLM": {
      "ai_languageModel": [
        [
          {
            "node": "AI Teacher Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Teacher Agent": {
      "main": [
        [
          {
            "node": "Log Q&A to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Fields": {
      "main": [
        [
          {
            "node": "AI Teacher Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classifier Memory": {
      "ai_memory": [
        [
          {
            "node": "Intent Classifier",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classifier": {
      "main": [
        [
          {
            "node": "Fetch System Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Q&A to Sheets": {
      "main": [
        [
          {
            "node": "Format Response Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Book Knowledge Base",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Book Knowledge Base": {
      "ai_tool": [
        [
          {
            "node": "AI Teacher Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch System Prompt": {
      "main": [
        [
          {
            "node": "Merge Input and Prompt",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Input and Prompt": {
      "main": [
        [
          {
            "node": "Aggregate Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Teacher Session Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Teacher Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  }
}