{
  "name": "Knowledge Base Retreive Implementation Plan",
  "nodes": [
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "YOUR_DATABASE_ID_1",
          "mode": "list",
          "cachedResultName": "All Projects ",
          "cachedResultUrl": "https://www.notion.so/YOUR_DATABASE_ID_1"
        },
        "returnAll": true,
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -784,
        -128
      ],
      "id": "c635cc40-7584-4f9a-9c9b-05a10c0b0d1c",
      "name": "Get all projets",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "path": "select-interface",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1008,
        -128
      ],
      "id": "9d1017b9-62c5-4959-acad-23e12d68ba45",
      "name": "Webhook"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Project & Task Selector</title>\n    <style>\n        /* Discord-inspired Dark Theme */\n        :root {\n            --bg-main: #313338;\n            --bg-card: #2b2d31;\n            --bg-input: #1e1f22;\n            --text-main: #dbdee1;\n            --text-muted: #949ba4;\n            --accent: #5865f2; /* Discord Blurple */\n            --accent-hover: #4752c4;\n            --border: #1e1f22;\n            --success: #23a559;\n        }\n\n        body { \n            font-family: 'gg sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; \n            padding: 40px; \n            background-color: var(--bg-main); \n            color: var(--text-main);\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            min-height: 80vh;\n        }\n\n        .card { \n            background-color: var(--bg-card); \n            padding: 32px; \n            border-radius: 8px; \n            box-shadow: 0 4px 15px rgba(0,0,0,0.3); \n            width: 100%;\n            max-width: 440px; \n        }\n\n        h3 { margin-top: 0; color: #fff; font-size: 24px; }\n        label { display: block; margin-top: 20px; margin-bottom: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase; color: var(--text-muted); }\n\n        select, button { \n            width: 100%; \n            padding: 12px; \n            border-radius: 4px; \n            font-size: 16px;\n            transition: all 0.2s ease;\n            box-sizing: border-box;\n        }\n\n        select {\n            background-color: var(--bg-input);\n            color: var(--text-main);\n            border: 1px solid var(--border);\n            outline: none;\n            cursor: pointer;\n        }\n\n        select:focus { border-color: var(--accent); }\n\n        button { \n            background-color: var(--accent); \n            color: white; \n            border: none; \n            cursor: pointer; \n            font-weight: 600; \n            margin-top: 30px;\n        }\n\n        button:hover:not(:disabled) { background-color: var(--accent-hover); }\n        button:disabled { opacity: 0.5; cursor: not-allowed; }\n\n        .success-state { text-align: center; }\n        .success-state h1 { color: var(--success); }\n    </style>\n</head>\n<body>\n    <div class=\"card\" id=\"mainCard\">\n        <h3>Selection Portal</h3>\n        \n        <label>1. Select Project</label>\n        <select id=\"projectPicker\" onchange=\"updateTasks()\">\n            <option value=\"\">-- Select Project --</option>\n            {{ $input.all().map(p => `<option value=\"${p.json.id}\">${p.json.name}</option>`).join('') }}\n        </select>\n\n        <label>2. Select Task</label>\n        <select id=\"taskPicker\" disabled>\n            <option>Select a project first...</option>\n        </select>\n\n        <button id=\"submitBtn\" onclick=\"submitForm()\" disabled>Start Workflow</button>\n    </div>\n\n    <script>\n        /**\n         * SMART URL HELPER\n         * Detects if we are in /webhook/ or /webhook-test/ automatically\n         */\n        const getWebhookBase = () => {\n            const path = window.location.pathname;\n            return path.substring(0, path.lastIndexOf('/') + 1);\n        };\n\n        async function updateTasks() {\n    const projectId = document.getElementById('projectPicker').value;\n    const taskPicker = document.getElementById('taskPicker');\n    const submitBtn = document.getElementById('submitBtn');\n\n    if (!projectId) return;\n\n    try {\n        const response = await fetch(`${getWebhookBase()}fetch-tasks`, {\n            method: 'POST',\n            headers: {'Content-Type': 'application/json'},\n            body: JSON.stringify({ projectId })\n        });\n        \n        const tasks = await response.json();\n\n        // UPDATED: Now showing the name AND the topics in the dropdown\n        taskPicker.innerHTML = tasks.map(t => `\n            <option value=\"${t.id}\">\n                ${t.name} [${t.topics}]\n            </option>\n        `).join('');\n        \n        taskPicker.disabled = false;\n        submitBtn.disabled = false;\n    } catch (err) {\n        console.error(\"Fetch error:\", err);\n    }\n}\n\n       async function submitForm() {\n    const taskSelect = document.getElementById('taskPicker');\n    const taskId = taskSelect.value;\n    \n    // Logic to find the topics array for the selected task\n    const selectedTaskName = taskSelect.options[taskSelect.selectedIndex].text;\n    \n    // We send the ID and whatever context we need to Path C\n    await fetch(`${getWebhookBase()}submit-selection`, {\n        method: 'POST',\n        headers: {'Content-Type': 'application/json'},\n        body: JSON.stringify({ \n            taskId: taskId,\n            taskName: selectedTaskName\n            // Note: Path C can pull the fresh topics array directly from Notion \n            // using the taskId to ensure 100% accuracy.\n        })\n    });\n\n    document.body.innerHTML = `<div class=\"card\"><h1>Context Exported</h1><p>Ready for Antigravity.</p></div>`;\n}\n    </script>\n</body>\n</html>",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        -560,
        -128
      ],
      "id": "4c2fe8fe-fa25-4125-9e0d-20d2c177f866",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "fetch-tasks",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1008,
        96
      ],
      "id": "afb9723d-d4ca-47aa-9f79-a241e2c14813",
      "name": "Webhook1"
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "YOUR_DATABASE_ID_2",
          "mode": "list",
          "cachedResultName": "Creating High Converting Landing Page + Social Media Brand ",
          "cachedResultUrl": "https://www.notion.so/YOUR_DATABASE_ID_2"
        },
        "filterType": "manual",
        "matchType": "allFilters",
        "filters": {
          "conditions": [
            {
              "key": "Project|relation",
              "condition": "contains",
              "relationValue": "={{ $json.body.projectId }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -784,
        96
      ],
      "id": "fd722b9d-b81c-4218-891a-c7209c4ececf",
      "name": "Get many database pages",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json.tasks }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        -336,
        96
      ],
      "id": "a8054398-b71b-444c-897c-ad7ccabefc9a",
      "name": "Respond to Webhook1"
    },
    {
      "parameters": {
        "jsCode": "return {\n  tasks: $input.all().map(item => ({\n    id: item.json.id,\n    name: item.json.name,\n    topics: item.json.property_topic // Keep as pure Array: [\"UI/UX\", \"Business\"]\n  }))\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -560,
        96
      ],
      "id": "5bcb7a1e-205f-4571-a440-f360289b3112",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "content": "## Receive project list",
        "height": 192,
        "width": 1232
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1352,
        -160
      ],
      "typeVersion": 1,
      "id": "19fd7fb9-f41e-44f9-8111-4da71a336f1e",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Recieve Project Tasks\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/components/sticky-notes/)",
        "width": 1232,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        64
      ],
      "typeVersion": 1,
      "id": "151e0034-089b-4b2e-a5e6-38703d5bcee6",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "submit-selection",
        "responseMode": "responseNode",
        "options": {
          "allowedOrigins": "*"
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1008,
        320
      ],
      "id": "203c8c70-f012-42c8-8bc8-35a5adaf4f24",
      "name": "Webhook2"
    },
    {
      "parameters": {
        "respondWith": "binary",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        336,
        320
      ],
      "id": "cc0eb411-fef0-4a70-9552-9ec54107462e",
      "name": "Respond to Webhook2"
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "get",
        "pageId": {
          "__rl": true,
          "value": "={{ $json.body.taskId }}",
          "mode": "id"
        }
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -784,
        320
      ],
      "id": "8f8486f0-3766-4a39-ae55-6b23d7337f4c",
      "name": "Get task",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "YOUR_DATABASE_ID_3",
          "mode": "list",
          "cachedResultName": "Knowledge",
          "cachedResultUrl": "https://www.notion.so/YOUR_DATABASE_ID_3"
        },
        "returnAll": true,
        "filterType": "manual",
        "filters": {
          "conditions": [
            {
              "key": "Topic|multi_select",
              "condition": "contains",
              "multiSelectValue": "={{ $json.property_topic }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        -560,
        320
      ],
      "id": "4b6c684d-c2b2-444a-b678-894c3f2e23d6",
      "name": "Get Notes",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "fileContent",
        "options": {
          "fileName": "references.txt"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        112,
        320
      ],
      "id": "2708aec9-3bde-4e30-ba28-e7f706d4c795",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "fieldsToSummarize": {
          "values": [
            {
              "aggregation": "concatenate",
              "field": "=id",
              "separateBy": "\n"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.summarize",
      "typeVersion": 1.1,
      "position": [
        -336,
        320
      ],
      "id": "5f8d9004-4315-45da-9eb1-b04bcfbaa0d6",
      "name": "Summarize"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "09c7f6f5-ca2e-4015-b6ba-87bb4d40d6f6",
              "name": "fileContent",
              "value": "={{ $('Get task').item.json.name }}\n{{ $json.concatenated_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -112,
        320
      ],
      "id": "cb21bed3-3410-40e5-befd-b2e952443219",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "content": "## Get Notes\n \n",
        "height": 208,
        "width": 1664,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        288
      ],
      "typeVersion": 1,
      "id": "7b3dc77b-253e-4e52-8f7f-818fe14299ab",
      "name": "Sticky Note2"
    }
  ],
  "connections": {
    "Get all projets": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Get all projets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook1": {
      "main": [
        [
          {
            "node": "Get many database pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many database pages": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Respond to Webhook1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook2": {
      "main": [
        [
          {
            "node": "Get task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get task": {
      "main": [
        [
          {
            "node": "Get Notes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Notes": {
      "main": [
        [
          {
            "node": "Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Respond to Webhook2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "YOUR_VERSION_ID",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "YOUR_WORKFLOW_ID",
  "tags": []
}