{
  "name": "Build a cost-efficient Lookio RAG chatbot with GPT-4.1 models for knowledge Q&A",
  "nodes": [
    {
      "id": "60c2f847-f213-4ca2-8b93-85435a34613c",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -176,
        496
      ]
    },
    {
      "id": "b99d2ceb-4a45-48b9-85ff-50d8b9e4c6fa",
      "name": "Very small model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        480,
        944
      ]
    },
    {
      "id": "798c5cdd-38b7-4883-979b-caf044011598",
      "name": "Simple response",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        960,
        304
      ]
    },
    {
      "id": "bd15aa9e-f288-4033-ba56-ae740f41de1f",
      "name": "Prepare retrieval query",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        784,
        704
      ]
    },
    {
      "id": "c07a6c01-9c13-47aa-896d-60e3f0f9992d",
      "name": "Write the final response",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1520,
        704
      ]
    },
    {
      "id": "aa532ba1-b606-45c0-8bb2-baeb63daf714",
      "name": "Mini model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        848,
        896
      ]
    },
    {
      "id": "834eb57c-ded3-46f9-8912-2a323f1f091f",
      "name": "Large model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1584,
        896
      ]
    },
    {
      "id": "4e006500-9e61-45e3-bb20-28cf342667a8",
      "name": "RAG via Lookio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1216,
        704
      ]
    },
    {
      "id": "d90f9ab0-5dd5-46ef-a87a-83f3e077fab9",
      "name": "Intent router",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        400,
        496
      ]
    },
    {
      "id": "f83304af-f74a-4aed-8a64-d7b657a9abaa",
      "name": "Respond to Chat",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        1904,
        496
      ]
    },
    {
      "id": "e89d675e-eac6-4e95-9238-d7b3501e1b2d",
      "name": "Find past messages",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        48,
        496
      ]
    },
    {
      "id": "735ad901-9c58-4851-bf1b-d93aaf46d557",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        208,
        720
      ]
    },
    {
      "id": "e1f44ef4-86c7-428b-8e6c-cc35d3181123",
      "name": "Store messages",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        2128,
        496
      ]
    },
    {
      "id": "61bf6661-fb9b-4179-b2b7-52f66c13cd39",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        672
      ],
      "parameters": {
        "width": 256,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Action required\n\nMake sure to set your Lookio API key and workspace ID in here."
      }
    },
    {
      "id": "5a21675c-622b-48d5-b076-3c30eb861811",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        224
      ],
      "parameters": {
        "width": 432,
        "height": 576,
        "content": "# **Smart & Efficient RAG Chatbot**\n\nThis workflow optimizes AI costs and speed by using an **Intent Router** pattern. \n\nInstead of one big model doing everything, it routes simple chats to small mode"
      }
    },
    {
      "id": "d7dde290-e168-4dd2-b6fd-5b1ee6a592bd",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        368
      ],
      "parameters": {
        "width": 582,
        "height": 320,
        "content": "## 1. Receive user message & load the conversation"
      }
    },
    {
      "id": "744c2765-8163-4e99-bc8c-36d83cf659ab",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        368
      ],
      "parameters": {
        "width": 374,
        "height": 320,
        "content": "## 2. AI confirms if powerful RAG is needed"
      }
    },
    {
      "id": "9275c57e-f39a-4a29-bf23-0bf5082df61c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        208
      ],
      "parameters": {
        "width": 374,
        "height": 256,
        "content": "## 3.1. writing a simple response"
      }
    },
    {
      "id": "37947331-e585-4f8e-ad43-90a2449a4458",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        608
      ],
      "parameters": {
        "width": 1046,
        "height": 432,
        "content": "## 3.2. Writing an AI knowledge retrieval based response"
      }
    },
    {
      "id": "16863033-491b-47df-9da3-ef4f190569d1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        400
      ],
      "parameters": {
        "width": 598,
        "height": 272,
        "content": "## 4. Response handling"
      }
    }
  ],
  "connections": {
    "Mini model": {
      "ai_languageModel": [
        [
          {
            "node": "Prepare retrieval query",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Large model": {
      "ai_languageModel": [
        [
          {
            "node": "Write the final response",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Intent router": {
      "main": [
        [
          {
            "node": "Simple response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare retrieval query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Find past messages",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Store messages",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "RAG via Lookio": {
      "main": [
        [
          {
            "node": "Write the final response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store messages": {
      "main": [
        []
      ]
    },
    "Respond to Chat": {
      "main": [
        [
          {
            "node": "Store messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple response": {
      "main": [
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Very small model": {
      "ai_languageModel": [
        [
          {
            "node": "Simple response",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Intent router",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Find past messages": {
      "main": [
        [
          {
            "node": "Intent router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare retrieval query": {
      "main": [
        [
          {
            "node": "RAG via Lookio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the final response": {
      "main": [
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Find past messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}