{
  "name": "Build custom workflows automatically with GPT-4o, RAG, and web search",
  "nodes": [
    {
      "id": "ee1c8a9a-e0fb-46d2-8274-140f5b297fba",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -2320,
        240
      ]
    },
    {
      "id": "243ba102-72bf-441a-b247-d784b3b054bd",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1920,
        240
      ]
    },
    {
      "id": "e36992ff-fa9c-469c-a669-267bcdccae99",
      "name": "Embeddings OpenAI2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -2120,
        -380
      ]
    },
    {
      "id": "5e709878-fc9d-4ed3-bfbb-b019f9c287db",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        -2000,
        -380
      ]
    },
    {
      "id": "f70e1fe1-618f-45c8-8379-f4742effb93b",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2320,
        -1060
      ]
    },
    {
      "id": "b34a7b23-f5b9-4046-9c92-a663698c0e92",
      "name": "Extract",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1880,
        -1060
      ]
    },
    {
      "id": "ea2a97ef-f2bb-4934-a040-7fa96b918101",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -1240,
        -1060
      ]
    },
    {
      "id": "a34dea8f-fb4f-4c94-834d-eb5948cc7286",
      "name": "Get Results",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1440,
        -1060
      ]
    },
    {
      "id": "63cd8437-92c9-4a33-aabf-3238b7b4a919",
      "name": "30 Secs",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1660,
        -1060
      ]
    },
    {
      "id": "c6830132-8d74-4209-9d41-6c42c1fb7e66",
      "name": "10 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1120,
        -1260
      ]
    },
    {
      "id": "95161389-9ea0-484b-abdf-82a8a0479b9a",
      "name": "SerpAPI",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1980,
        580
      ]
    },
    {
      "id": "da8d5a8a-c641-453f-a7bb-817099e8592f",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        -1860,
        580
      ]
    },
    {
      "id": "0838fd0e-8e1b-4c37-8c31-8ab9306fff89",
      "name": "Train Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        -2120,
        -540
      ]
    },
    {
      "id": "b4bca1b1-80bc-42fa-b434-00eabd926aff",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -2100,
        580
      ]
    },
    {
      "id": "e9f693e5-4733-4987-a7a8-7f6b7823b221",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -1840,
        720
      ]
    },
    {
      "id": "ebe6227a-4f12-44d0-ae8c-516e89e31f9f",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -1520,
        240
      ]
    },
    {
      "id": "afcb27aa-257f-4c9a-8cb2-d54f23123443",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -1160,
        240
      ]
    },
    {
      "id": "8b7a4793-141f-499d-b52d-a397be147d12",
      "name": "Web Crawler Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3940,
        -1200
      ],
      "parameters": {
        "width": 780,
        "height": 340,
        "content": "🕸️ **Web Crawler (Sub-process #1)**\n\n*Triggered manually.*\n1. **Edit Fields → Extract** – sends a Firecrawl request to scrape docs.n8n.io.\n2. **Wait (30 s) → Get Results** – polls Firecrawl until scra"
      }
    },
    {
      "id": "ac612a9e-d148-4b24-a98a-c672de2177e8",
      "name": "RAG Trainer Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3940,
        -520
      ],
      "parameters": {
        "width": 780,
        "height": 320,
        "content": "🧠 **RAG Trainer (Sub-process #2)**\n\n1. **Default Data Loader → Recursive Splitter** – loads the crawled pages and breaks them into ~1-2 k-token chunks.\n2. **Embeddings (OpenAI) → Train Pinecone** – tu"
      }
    },
    {
      "id": "b25bafe7-c25c-4b79-9e1b-0e9610f6f815",
      "name": "Agent Builder Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3940,
        240
      ],
      "parameters": {
        "width": 820,
        "height": 520,
        "content": "🤖 **AI Agent Builder (Sub-process #3)**\n\n1. **Chat Trigger** – waits for a user request (e.g. in GPT-style chat).\n2. **AI Agent (LangChain)** – orchestrates:\n   • **OpenRouter GPT-4o** (LLM)\n   • **Se"
      }
    },
    {
      "id": "4d5e930d-1d9d-479d-a9fd-c57b8824b57c",
      "name": "Configure Firecrawl",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        -1200
      ],
      "parameters": {
        "width": 660,
        "height": 340,
        "content": "⚙️ **Firecrawl API**\nNodes: **HTTP Request – “Extract”** & **“Get Results”**\n1. Create a *Generic Credential (Header Auth)*.\n2. Header name: `Authorization`\n3. Value: `Bearer YOUR_TOKEN_HERE`.\n4. Sele"
      }
    },
    {
      "id": "2c058520-9532-4108-a514-9db857250cd0",
      "name": "Configure Pinecone",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        -520
      ],
      "parameters": {
        "width": 660,
        "height": 140,
        "content": "⚙️ **Pinecone Vector Store**\nNodes: **“Train Pinecone Vector Store”** & **“Pinecone Vector Store”**\n• Add a *Pinecone API* credential with **Environment**, **API Key**, and **Index Name**.\n• Make sure"
      }
    },
    {
      "id": "b8b327e6-069f-4dff-a5ce-6fed6e9a117d",
      "name": "Configure OpenAI API",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        -360
      ],
      "parameters": {
        "width": 660,
        "height": null,
        "content": "⚙️ **OpenAI / Azure OpenAI**\nNodes: **“Embeddings OpenAI”**, **“Embeddings OpenAI 2”**, **“OpenAI (validator)”**\n1. Create an *OpenAI API* credential (or Azure equivalent).\n2. Select the credential in"
      }
    },
    {
      "id": "42784df1-903f-43d5-92ed-c25cf2df5323",
      "name": "Configure OpenRouter GPT-4o",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3100,
        240
      ],
      "parameters": {
        "width": 620,
        "height": 100,
        "content": "⚙️ **OpenRouter API**\nNode: **“OpenRouter Chat Model”**\n• Create an *OpenRouter API Key* credential and select it here.\n• The example uses model `o4-mini-2025-04-16`; adjust if your plan differs."
      }
    },
    {
      "id": "debda5ff-2309-410a-a8f6-7e6fd011fdc1",
      "name": "Configure SerpAPI",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3100,
        360
      ],
      "parameters": {
        "width": 620,
        "height": 100,
        "content": "⚙️ **SerpAPI Key**\nNode: **“SerpAPI”**\n1. Sign up at serpapi.com and copy your key.\n2. Add a *SerpAPI* credential and select it in the node."
      }
    },
    {
      "id": "f2d27faa-06f4-42bf-882f-3ce35ad6f876",
      "name": "Configure Pinecone1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3100,
        480
      ],
      "parameters": {
        "width": 620,
        "height": 100,
        "content": "⚙️ **Pinecone Vector Store**\nNodes: **“Train Pinecone Vector Store”** & **“Pinecone Vector Store”**\n• Add a *Pinecone API* credential with **Environment**, **API Key**, and **Index Name**.\n• Make sure"
      }
    },
    {
      "id": "3b78511a-b49a-46cf-b3ca-6dba4a6d68cf",
      "name": "Configure OpenAI API1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3100,
        600
      ],
      "parameters": {
        "width": 620,
        "height": null,
        "content": "⚙️ **OpenAI / Azure OpenAI**\nNodes: **“Embeddings OpenAI”**, **“Embeddings OpenAI 2”**, **“OpenAI (validator)”**\n1. Create an *OpenAI API* credential (or Azure equivalent).\n2. Select the credential in"
      }
    },
    {
      "id": "a802de97-238c-4f7f-9024-43d3fb14f7a8",
      "name": "Extract JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        -920,
        240
      ]
    },
    {
      "id": "d67d0970-0f58-41f4-8d48-077247eb4b0a",
      "name": "Set Preferences",
      "type": "n8n-nodes-base.set",
      "position": [
        -2320,
        80
      ]
    },
    {
      "id": "392f160f-5ffd-4799-a63d-adc240b7f26a",
      "name": "Convert to JSON File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -720,
        240
      ]
    },
    {
      "id": "efc08c98-cb77-45f0-b824-de2a22dee2fc",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -2320,
        -540
      ]
    },
    {
      "id": "9ff243d3-1871-4634-b5a6-dd9a745a7a84",
      "name": "Set URL",
      "type": "n8n-nodes-base.set",
      "position": [
        -2100,
        -1060
      ]
    },
    {
      "id": "03e4cd15-b458-4601-a9d4-c365a27e846e",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        -1980,
        -240
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "10 Seconds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Extract JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "30 Secs": {
      "main": [
        [
          {
            "node": "Get Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract": {
      "main": [
        [
          {
            "node": "30 Secs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Set URL": {
      "main": [
        [
          {
            "node": "Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "10 Seconds": {
      "main": [
        [
          {
            "node": "Get Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Results": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract JSON": {
      "main": [
        [
          {
            "node": "Convert to JSON File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Train Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Preferences": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Train Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Convert to JSON File": {
      "main": [
        []
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Train Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Set URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}