{
  "name": "AI agent to chat with Airtable and analyze data",
  "nodes": [
    {
      "id": "799d2e0c-29b9-494c-b11a-d79c7ed4a06d",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        920,
        480
      ]
    },
    {
      "id": "6254ef4e-9699-404e-96a4-569326cce48d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1160,
        200
      ]
    },
    {
      "id": "227a5427-c270-47dc-bc08-4bb321314926",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1740,
        620
      ],
      "parameters": {
        "width": null,
        "height": 80,
        "content": "### Replace Mapbox public key - <your_public_key> in code"
      }
    },
    {
      "id": "667751f4-9815-45b7-8dd2-9a0821a7a5a7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        640
      ],
      "parameters": {
        "width": null,
        "height": 80,
        "content": "### Replace OpenAI connection"
      }
    },
    {
      "id": "a9cdec25-4167-44a9-9d3c-fb04aac7bb32",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1080,
        480
      ]
    },
    {
      "id": "dfab4eb2-ba30-4756-8a52-5d73de9fba53",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        940,
        200
      ]
    },
    {
      "id": "259e3d13-ca92-4756-af69-34065dbe08f3",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        760,
        1340
      ]
    },
    {
      "id": "5b80c2c8-7649-40f2-b9be-d090d8bd5ae9",
      "name": "Response",
      "type": "n8n-nodes-base.set",
      "position": [
        2740,
        1360
      ]
    },
    {
      "id": "761f5593-f85c-44cd-abbd-aeac78bc31f8",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        980,
        1320
      ]
    },
    {
      "id": "d6252c5b-a820-4ded-b59b-ab2fb2e277c3",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1780,
        980
      ]
    },
    {
      "id": "1442ca2e-1793-4029-b398-61d6e6f1c346",
      "name": "Aggregate1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1780,
        1140
      ]
    },
    {
      "id": "a81b4dcc-c999-43be-a0ea-e37f3c7c9f9d",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1960,
        1360
      ]
    },
    {
      "id": "8029213c-fd8a-4673-a2a0-11b90fd23971",
      "name": "Aggregate2",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2260,
        1360
      ]
    },
    {
      "id": "f5f99038-9d19-49ed-9f50-3cd0270bf9ce",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        2120,
        1720
      ]
    },
    {
      "id": "abc7ddae-9ca9-4cf6-89a4-a63da8c1e036",
      "name": "Response1",
      "type": "n8n-nodes-base.set",
      "position": [
        2760,
        1720
      ]
    },
    {
      "id": "6f40d50f-70e8-4b64-aa42-ae9262fb8381",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        1520
      ],
      "parameters": {
        "width": 160,
        "height": 80,
        "content": "### Replace Airtable connection"
      }
    },
    {
      "id": "de99a161-5ab3-4b54-bdf7-340d74aa5a93",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1740,
        1600
      ],
      "parameters": {
        "width": 160,
        "height": 80,
        "content": "### Replace OpenAI connection"
      }
    },
    {
      "id": "c1e030fd-4449-43ca-a4e7-a863f9487614",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1540,
        860
      ],
      "parameters": {
        "width": 160,
        "height": 80,
        "content": "### Replace Airtable connection"
      }
    },
    {
      "id": "4375d3a4-0b3b-4de6-9db7-42af4148af2b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        1900
      ],
      "parameters": {
        "width": 1180,
        "height": 80,
        "content": "### Replace OpenAI connection"
      }
    },
    {
      "id": "138f813c-d0b0-4a2b-8833-69f1decc9253",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        0
      ],
      "parameters": {
        "width": 1320,
        "height": 780,
        "content": "### Workflow 1"
      }
    },
    {
      "id": "ca87c7b7-ab34-4ff9-8d74-cef90e6f1e5e",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        840
      ],
      "parameters": {
        "width": 2240,
        "height": 1180,
        "content": "### Workflow 2"
      }
    },
    {
      "id": "a5cdf41a-f2ca-4203-94ce-45795395ea92",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        680
      ],
      "parameters": {
        "width": 330.5152611046425,
        "height": 239.5888196628349,
        "content": "### ... or watch set up video [20 min]\n[![Youtube Thumbnail](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/Video%2012%20-%20Chat%20with%20Airtable%20Blur.png)](https://y"
      }
    },
    {
      "id": "697889c4-15e7-4099-89b8-f4e2e3a3abac",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 636,
        "height": 657,
        "content": "![5min Logo](https://cflobdhpqwnoisuctsoc.supabase.co/storage/v1/object/public/my_storage/banner.png)\n## AI Agent to chat with Airtable and analyze data\n**Made by [Mark Shcherbakov](https://www.linked"
      }
    },
    {
      "id": "a9f7c4fd-c07a-4c7c-875d-74b27e3f1fbf",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        680
      ],
      "parameters": {
        "width": 280,
        "height": 346,
        "content": "### Set up steps\n\n1. **Separate workflows**:\n\t- Create additional workflow and move there Workflow 2.\n\n2. **Replace credentials**:\n\t- Replace connections and credentials in all nodes.\n\n3. **Start chat"
      }
    },
    {
      "id": "0c86638f-7220-415d-a920-13761da925a6",
      "name": "Search records",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1500,
        480
      ]
    },
    {
      "id": "7ba1d6ac-f1a2-4b8d-a9a5-ce92eaa4e7fa",
      "name": "Process data with code",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1640,
        480
      ]
    },
    {
      "id": "3754175c-6f74-4750-b2e7-00e2bd3caf6d",
      "name": "Create map image",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        1800,
        480
      ]
    },
    {
      "id": "135078ea-6a3f-4aee-9f60-c6d5832e446e",
      "name": "Get list of bases",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1220,
        480
      ]
    },
    {
      "id": "cd4781d0-f873-4aea-951c-6809358c1db6",
      "name": "Get base schema",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        1360,
        480
      ]
    },
    {
      "id": "45c8b2eb-f43a-48b1-a270-9caeda9da0b0",
      "name": "Get Bases",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1580,
        980
      ]
    },
    {
      "id": "bb8036bc-1c23-461b-bd03-2461e31c6cb6",
      "name": "Get Base/Tables schema",
      "type": "n8n-nodes-base.airtable",
      "position": [
        1580,
        1140
      ]
    },
    {
      "id": "dab309d9-3629-44ba-9f0a-ede55f96488f",
      "name": "If filter description exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1340,
        1360
      ]
    },
    {
      "id": "4cc416aa-50bd-4b60-ae51-887c4ee97c88",
      "name": "Airtable - Search records",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2100,
        1360
      ]
    },
    {
      "id": "9dc71d31-8499-4b69-b87c-898217447d50",
      "name": "OpenAI - Generate search filter",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1760,
        1420
      ]
    },
    {
      "id": "16e4ea97-ea73-45a0-aa88-0f9a2969a6a3",
      "name": "Set schema and prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        1560,
        1420
      ]
    },
    {
      "id": "6e670074-8508-4282-9c40-600cc445b10f",
      "name": "Upload file to get link",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2580,
        1720
      ]
    },
    {
      "id": "b7569d19-3a10-41e5-932b-4be04260a58e",
      "name": "OpenAI - Download File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2360,
        1720
      ]
    },
    {
      "id": "bf378b21-07fb-4f9e-bfc5-9623ebcb8236",
      "name": "OpenAI - Get messages",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1960,
        1720
      ]
    },
    {
      "id": "9874eec1-61e2-45fe-8c57-556957a15473",
      "name": "OpenAI - Run assistant",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1760,
        1720
      ]
    },
    {
      "id": "e5339ad2-36c7-40c5-846b-2bd242f41ea5",
      "name": "OpenAI - Send message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1560,
        1720
      ]
    },
    {
      "id": "5b822c15-af63-43f6-ac30-61a34dcd91ee",
      "name": "OpenAI - Create thread",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        1720
      ]
    }
  ],
  "connections": {
    "If1": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OpenAI - Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Airtable - Search records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get Bases",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Base/Tables schema",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If filter description exists",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OpenAI - Create thread",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Bases": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate1": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate2": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search records": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get base schema": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create map image": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get list of bases": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Get messages": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Send message": {
      "main": [
        [
          {
            "node": "OpenAI - Run assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set schema and prompt": {
      "main": [
        [
          {
            "node": "OpenAI - Generate search filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Base/Tables schema": {
      "main": [
        [
          {
            "node": "Aggregate1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Create thread": {
      "main": [
        [
          {
            "node": "OpenAI - Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Download File": {
      "main": [
        [
          {
            "node": "Upload file to get link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Run assistant": {
      "main": [
        [
          {
            "node": "OpenAI - Get messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process data with code": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Upload file to get link": {
      "main": [
        [
          {
            "node": "Response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable - Search records": {
      "main": [
        [
          {
            "node": "Aggregate2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If filter description exists": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set schema and prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Generate search filter": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}