{
  "name": "Notion AI assistant generator",
  "nodes": [
    {
      "id": "9052b5b2-1e2d-425c-92e5-1ed51323e71c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        240
      ],
      "parameters": {
        "width": 616.7964812508943,
        "height": 231.27721611949534,
        "content": "# Generate new workflow version for specific notion db schema\nInput a Notion database URL and get an AI Assistant chatbot workflow for it based on this template: https://n8n.io/workflows/2413-notion-k"
      }
    },
    {
      "id": "b4a83f76-2bad-4bbe-9b7f-1df684166035",
      "name": "Notion",
      "type": "n8n-nodes-base.notion",
      "position": [
        1280,
        480
      ]
    },
    {
      "id": "39537c95-5ca0-47a9-b2bf-2c0134d3f236",
      "name": "Return success to chat",
      "type": "n8n-nodes-base.set",
      "position": [
        3540,
        740
      ]
    },
    {
      "id": "5ae0fcfb-c3e2-443d-9a0c-25e7b17dc189",
      "name": "Auto-fixing Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        2340,
        640
      ]
    },
    {
      "id": "4cd182ff-040a-4c0f-819f-a0648c67ab66",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        2100,
        640
      ]
    },
    {
      "id": "dc751c1f-4cd6-4d04-8152-402eb5e24574",
      "name": "Set schema for eval",
      "type": "n8n-nodes-base.set",
      "position": [
        2720,
        440
      ]
    },
    {
      "id": "8f8c9d29-c901-4c3c-83a6-23bfe51809bd",
      "name": "Return error to chat",
      "type": "n8n-nodes-base.set",
      "position": [
        1500,
        660
      ]
    },
    {
      "id": "518d2e58-6f2e-4497-9f74-7dbfeff4fd6f",
      "name": "Anthropic Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        2300,
        800
      ]
    },
    {
      "id": "0e7a4d05-db00-4915-9df4-d3cb79bf5789",
      "name": "standardize schema",
      "type": "n8n-nodes-base.set",
      "position": [
        1500,
        440
      ]
    },
    {
      "id": "8244fb04-75ec-4b41-93cf-e9c5755fabfd",
      "name": "Simplify properties object",
      "type": "n8n-nodes-base.code",
      "position": [
        1720,
        440
      ]
    },
    {
      "id": "41b615cc-de7d-4c3f-b608-2d1856e0541a",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2500,
        800
      ]
    },
    {
      "id": "8016baac-9242-44e6-b487-111bb560019d",
      "name": "Set input data",
      "type": "n8n-nodes-base.code",
      "position": [
        1980,
        440
      ]
    },
    {
      "id": "dc15a250-074e-4aed-8eec-5c60c91cc42d",
      "name": "Set schem for rerun",
      "type": "n8n-nodes-base.set",
      "position": [
        3540,
        240
      ]
    },
    {
      "id": "224f4963-caac-4438-a61b-90e2c0858f24",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1060,
        240
      ],
      "parameters": {
        "width": 747.234277816171,
        "height": 110.78786136085805,
        "content": "## #1 Serve chat, get URL from user, pull new notion DB schema\nUses n8n Chat trigger. Notion node will fail if an invalid URL is used, or if n8n doesn't have access to it. Also attempts to strip non U"
      }
    },
    {
      "id": "7e18ca8d-3181-446f-96f5-0e4b1000d855",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1939,
        240
      ],
      "parameters": {
        "width": 638.6509136143742,
        "height": 114.20873484539783,
        "content": "## #2 GenAI step\nTakes 2 inputs: [original workflow template](https://n8n.io/workflows/2413-notion-knowledge-base-ai-assistant/) and new Notion database details from #1"
      }
    },
    {
      "id": "b54b8c03-eb66-4ec7-bc7f-f62ddc566bbe",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2660,
        240
      ],
      "parameters": {
        "width": 727.8599253628195,
        "height": 111.9281525223713,
        "content": "## #3 Does the new workflow look right?\nChecks for previously identified cases (e.g. LLM outputs placeholder for certain values) then does general LLM check on whether it looks like valid n8n workflow"
      }
    },
    {
      "id": "a5cc97a7-33e3-45fe-9e13-45ebafd469d7",
      "name": "Add feedback prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        440
      ]
    },
    {
      "id": "b066fa2d-77ba-4466-ae3b-9ab2405bae3c",
      "name": "Check for WF JSON errors",
      "type": "n8n-nodes-base.switch",
      "position": [
        2920,
        440
      ]
    },
    {
      "id": "e4b38c13-255d-4136-9c7b-90678cbe523b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3540,
        60
      ],
      "parameters": {
        "width": 343.3887397891673,
        "height": 132.30907857627597,
        "content": "## #4 Respond to Chat trigger\nEach response to the chat trigger is one run. Data of the last node that runs in the workflow is sent to chat trigger, like `Return success to chat`"
      }
    },
    {
      "id": "3ecfadc2-2499-4e0f-94c4-1e68770beefb",
      "name": "Generate Workflow Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2220,
        440
      ]
    },
    {
      "id": "3ac37a66-30d5-404a-8c22-1402874e4f37",
      "name": "Anthropic Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        3120,
        860
      ]
    },
    {
      "id": "f71ddd6e-7d41-405c-8cd8-bb21fc0654ae",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1100,
        480
      ]
    },
    {
      "id": "5a549080-0ad0-4f94-87b1-8b735d7b95a3",
      "name": "Valid n8n workflow JSON?",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        3140,
        700
      ]
    },
    {
      "id": "02bf6e06-6671-4d18-ba30-117459e9d58a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        500
      ],
      "parameters": {
        "width": 614.8565246662145,
        "height": 416.2640726760381,
        "content": "## Watch a quick set up video 👇\n[![Notion AI Assistant Generator](https://uploads.n8n.io/devrel/notion-db-assistant-thumb#full-width)](https://youtu.be/iK87ppcaNgM)\n"
      }
    }
  ],
  "connections": {
    "Notion": {
      "main": [
        [
          {
            "node": "standardize schema",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return error to chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set input data": {
      "main": [
        [
          {
            "node": "Generate Workflow Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "standardize schema": {
      "main": [
        [
          {
            "node": "Simplify properties object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add feedback prompt": {
      "main": [
        [
          {
            "node": "Set schem for rerun",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set schem for rerun": {
      "main": [
        [
          {
            "node": "Set input data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set schema for eval": {
      "main": [
        [
          {
            "node": "Check for WF JSON errors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Workflow Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Valid n8n workflow JSON?",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Workflow Agent": {
      "main": [
        [
          {
            "node": "Set schema for eval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for WF JSON errors": {
      "main": [
        [
          {
            "node": "Add feedback prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Valid n8n workflow JSON?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Valid n8n workflow JSON?": {
      "main": [
        [
          {
            "node": "Set schem for rerun",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return success to chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto-fixing Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Workflow Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Simplify properties object": {
      "main": [
        [
          {
            "node": "Set input data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}