{
  "name": "AI agent to chat with Snowflake database",
  "nodes": [
    {
      "id": "695a7e9f-01c6-4290-a085-55099d8db7db",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1100,
        -280
      ]
    },
    {
      "id": "6971de5a-a520-4f74-a5c4-87039b22a15f",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1340,
        -280
      ]
    },
    {
      "id": "f14d403f-a3d1-4535-aaca-767f9258166c",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1140,
        -80
      ]
    },
    {
      "id": "7f57e580-ac48-4926-8dda-5ae581ca7345",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1260,
        -80
      ]
    },
    {
      "id": "f809bc79-d5ed-466c-82c2-4c298a079f10",
      "name": "DB Schema1",
      "type": "n8n-nodes-base.snowflakeTool",
      "position": [
        1540,
        -80
      ]
    },
    {
      "id": "68907f64-aa11-4044-b2ba-d7796fff90f4",
      "name": "Get table definition",
      "type": "n8n-nodes-base.snowflakeTool",
      "position": [
        1660,
        -80
      ]
    },
    {
      "id": "226b3c2e-7058-476e-a96c-d6cf8bd4f53b",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1000,
        860
      ]
    },
    {
      "id": "f7abd0a8-8aa4-4aa7-ae24-22d40736c67f",
      "name": "Set HTML",
      "type": "n8n-nodes-base.set",
      "position": [
        1600,
        860
      ]
    },
    {
      "id": "e08d0061-a5b9-452d-aae1-dd06c5e76478",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2020,
        860
      ]
    },
    {
      "id": "caec4943-2a9e-4c93-b9f0-46c05e1c977b",
      "name": "Snowflake1",
      "type": "n8n-nodes-base.snowflake",
      "position": [
        1200,
        860
      ]
    },
    {
      "id": "7bf75ddf-38df-454d-908f-32cbeb785464",
      "name": "Aggregate1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1420,
        860
      ]
    },
    {
      "id": "eb82d533-e0a0-4328-a31c-39433cf45740",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        1000,
        320
      ]
    },
    {
      "id": "3b69b3eb-7a91-43b3-8839-13b5bbdf3203",
      "name": "Retrieve Data",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1400,
        -80
      ]
    },
    {
      "id": "8968d722-6b26-42d9-b750-0b13c382f7ab",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        120
      ],
      "parameters": {
        "width": 1140,
        "height": 560,
        "content": "### Tool\n"
      }
    },
    {
      "id": "33544700-b10f-441a-852c-0f985158cb5c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        720
      ],
      "parameters": {
        "width": 1360,
        "height": 480,
        "content": "### Report workflow"
      }
    },
    {
      "id": "d279cb96-4fc5-4554-9363-669aea575926",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        -360
      ],
      "parameters": {
        "width": 900,
        "height": 440,
        "content": "### Agent"
      }
    },
    {
      "id": "fc341443-ec9c-4005-8b67-dce59e8b4119",
      "name": "Execute SQL",
      "type": "n8n-nodes-base.snowflake",
      "position": [
        1200,
        320
      ]
    },
    {
      "id": "935f1932-e803-4daf-89ae-e3ce9f322962",
      "name": "Aggregate Data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1420,
        260
      ]
    },
    {
      "id": "1c7362be-e338-4976-8a18-a40f11e01ef1",
      "name": "If Count>100",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        280
      ]
    },
    {
      "id": "36440a5e-d254-4995-be8e-2e8313b8bc29",
      "name": "Link to Report",
      "type": "n8n-nodes-base.set",
      "position": [
        1800,
        200
      ]
    },
    {
      "id": "c581ea63-c210-4df9-b029-f58c1c8da75d",
      "name": "Return Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1800,
        360
      ]
    },
    {
      "id": "4fa89cd3-64d8-40cf-87f1-d604aca9c7eb",
      "name": "Return Error",
      "type": "n8n-nodes-base.set",
      "position": [
        1600,
        460
      ]
    },
    {
      "id": "c67e5a20-e116-4955-bc66-fe8b4384b284",
      "name": "Error page",
      "type": "n8n-nodes-base.set",
      "position": [
        1800,
        1000
      ]
    },
    {
      "id": "f614bdcc-e19a-4048-9b13-2adf8b416e56",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1980,
        200
      ],
      "parameters": {
        "width": null,
        "height": 80,
        "content": "### Replace webhook address"
      }
    },
    {
      "id": "6ac29201-e714-4d00-b9ca-e2063267dcb3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        60
      ],
      "parameters": {
        "width": 160,
        "height": 80,
        "content": "### Map this workflow"
      }
    },
    {
      "id": "3955749d-31e0-4dc8-9e39-13c1f3de700d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1540,
        60
      ],
      "parameters": {
        "width": null,
        "height": 80,
        "content": "### Replace name of schema and database"
      }
    },
    {
      "id": "b71fbe78-5527-4857-a259-bfa9fc0a0537",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        -360
      ],
      "parameters": {
        "width": 636.2128494576581,
        "height": 497.1532689930921,
        "content": "![5min Logo](https://res.cloudinary.com/de9jgixzm/image/upload/Skool%20Assets/ejm3hqnvhgwpnu2fv92s)\n## AI Agent to chat with Snowflake database with UI\n**Made by [Mark Shcherbakov](https://www.linkedi"
      }
    },
    {
      "id": "a207fdbc-7223-49ed-9798-9d3415634b39",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        160
      ],
      "parameters": {
        "width": 330.5152611046425,
        "height": 240.6839895136402,
        "content": "### ... or watch set up video [5 min]\n[![Youtube Thumbnail](https://res.cloudinary.com/de9jgixzm/image/upload/nvg4dvgajspjzqudh2wa)](https://youtu.be/r7er-HCRsX4)\n"
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Snowflake1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set HTML": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        []
      ]
    },
    "Aggregate1": {
      "main": [
        [
          {
            "node": "Set HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DB Schema1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Error page": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Snowflake1": {
      "main": [
        [
          {
            "node": "Aggregate1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute SQL": {
      "main": [
        [
          {
            "node": "Aggregate Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Count>100": {
      "main": [
        [
          {
            "node": "Link to Report",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Data": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Data": {
      "main": [
        [
          {
            "node": "If Count>100",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get table definition": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Execute SQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}