{
  "name": "Ai data extraction with dynamic prompts and Airtable",
  "nodes": [
    {
      "id": "36816ae7-414a-482e-8a50-021885237273",
      "name": "Event Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -220,
        -140
      ]
    },
    {
      "id": "920ca6d8-7a6e-4482-b003-fa643f550a85",
      "name": "Get Prompt Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        -900,
        -140
      ]
    },
    {
      "id": "3b73b2f5-9081-4633-911f-ef3041600a00",
      "name": "Get File Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1220,
        320
      ]
    },
    {
      "id": "e96edca8-9e8b-4ca4-bef9-dae673d3aba4",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1380,
        320
      ]
    },
    {
      "id": "b5c2b87b-5756-4810-84c9-34ea420bdcef",
      "name": "Get Result",
      "type": "n8n-nodes-base.set",
      "position": [
        2000,
        380
      ]
    },
    {
      "id": "a5cb0510-620b-469d-bf66-26ab64d6f88f",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        800,
        220
      ]
    },
    {
      "id": "20e24946-59d8-4b19-bfab-eebb02f7e46d",
      "name": "Row Reference",
      "type": "n8n-nodes-base.noOp",
      "position": [
        980,
        320
      ]
    },
    {
      "id": "4090c53e-e635-4421-ab2b-475bfc62cea4",
      "name": "Generate Field Value",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1540,
        320
      ]
    },
    {
      "id": "582d4008-4871-4798-bc24-abf774ad29b5",
      "name": "Fields to Update",
      "type": "n8n-nodes-base.code",
      "position": [
        1560,
        -300
      ]
    },
    {
      "id": "051c6a99-cec3-42df-9de7-47cb69b51682",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        820,
        -420
      ]
    },
    {
      "id": "f559c8ff-2ee5-478d-84ee-6b0ca2fe2050",
      "name": "Row Ref",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1000,
        -300
      ]
    },
    {
      "id": "7b82cc73-67cb-46d7-a1d4-19712c86890a",
      "name": "Get File Data1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1240,
        -300
      ]
    },
    {
      "id": "7ef1556c-96a3-4988-982d-ec8c5fba4601",
      "name": "Extract from File1",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1400,
        -300
      ]
    },
    {
      "id": "9916f1c1-f413-4996-ad45-380a899b4a88",
      "name": "Get Result1",
      "type": "n8n-nodes-base.set",
      "position": [
        2120,
        -260
      ]
    },
    {
      "id": "f62f612d-c288-4062-ab3c-dbc24c9b4b38",
      "name": "Generate Field Value1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1720,
        -300
      ]
    },
    {
      "id": "615f7436-f280-4033-8ec8-a34f1bd78075",
      "name": "Filter Valid Rows",
      "type": "n8n-nodes-base.filter",
      "position": [
        520,
        -420
      ]
    },
    {
      "id": "281b9fb0-305c-4a0c-b73b-82b6ba876d12",
      "name": "Filter Valid Fields",
      "type": "n8n-nodes-base.filter",
      "position": [
        340,
        220
      ]
    },
    {
      "id": "dd0fa792-791f-4d31-a7e8-9b72a25b6a07",
      "name": "Event Ref",
      "type": "n8n-nodes-base.noOp",
      "position": [
        160,
        220
      ]
    },
    {
      "id": "ca1174b3-da18-4d3c-86ef-3028cd5b12a7",
      "name": "Event Ref1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        160,
        -420
      ]
    },
    {
      "id": "8800b355-0fa8-4297-b13b-d3da8a01c3b7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        -340
      ],
      "parameters": {
        "width": 480,
        "height": 440,
        "content": "### 1. Get Table Schema\n[Learn more about the Airtable node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.airtable/)\n\nFor this operation, we'll use the handy Airtable node. I reco"
      }
    },
    {
      "id": "a90876d3-8a93-4d90-9e2a-f23de452259d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -440
      ],
      "parameters": {
        "width": 330,
        "height": 80,
        "content": "### 2a. Updates Minimal Number of Rows\nThis branch updates only the rows impacted."
      }
    },
    {
      "id": "319adf97-8b14-4069-b4cc-594a6ea479c1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        140
      ],
      "parameters": {
        "width": 390,
        "height": 120,
        "content": "### 2b. Update Every Row under the Field\nThis branch updates all applicable rows under field when the field/column is created or changed. Watch out - if you have 1000s of rows, this could take a while"
      }
    },
    {
      "id": "42a60c8c-476f-4930-bac5-4d36a7185f4f",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2240,
        -1000
      ],
      "parameters": {
        "width": 520,
        "height": 1120,
        "content": "## Try It Out!\n### This n8n template powers a \"dynamic\" or \"user-defined\" prompts with PDF workflow pattern for a [Airtable](https://airtable.com/invite/r/cKzxFYVc) table. Simply put, it allows users "
      }
    },
    {
      "id": "c6d037e9-1bf7-47a7-9c46-940220e0786b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -340
      ],
      "parameters": {
        "width": 760,
        "height": 440,
        "content": "### 2. Event Router Pattern\n[Learn more about the Switch node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.switch/)\n\nA simple switch node can be used to determine which event to"
      }
    },
    {
      "id": "897cec32-3a4c-4a76-bffe-b1456c287b44",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -620
      ],
      "parameters": {
        "width": 620,
        "height": 400,
        "content": "### 3. Filter Only Rows with Valid Input\n[Learn more about the Split Out node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitout/)\n\nThis step handles one or more updated rows"
      }
    },
    {
      "id": "a5999ca3-4418-42c5-aa1c-fbdfb1c04fef",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2060,
        -480
      ],
      "parameters": {
        "width": 600,
        "height": 440,
        "content": "### 6. Update the Airtable Record\n[Learn more about the Edit Fields node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/)\n\nFinally, we can collect the LLM responses and combin"
      }
    },
    {
      "id": "38192929-a387-4240-8373-290499b40e5a",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        -580
      ],
      "parameters": {
        "width": 860,
        "height": 580,
        "content": "### 5. PDFs, LLMs and Dynamic Prompts? Oh My!\n[Learn more about the Basic LLM node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.chainllm/)\n\nThis step is where"
      }
    },
    {
      "id": "19a9b93a-d18f-4ffd-ae93-ed41cf398e90",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -580
      ],
      "parameters": {
        "width": 420,
        "height": 460,
        "content": "### 4. Using an Items Loop\n[Learn more about the Split in Batches node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches/)\n\nA split in batches node is used here to upd"
      }
    },
    {
      "id": "5407fead-ee7c-47c8-94ed-5b89e74e50e8",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        40
      ],
      "parameters": {
        "width": 600,
        "height": 360,
        "content": "### 7. Listing All Applicable Rows Under The Column\n[Learn more about the Filter node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.filter)\n\nTo keep things performant, we can dec"
      }
    },
    {
      "id": "43b0e330-b79a-4577-b4fc-314e8b790cf7",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1160,
        140
      ],
      "parameters": {
        "width": 700,
        "height": 500,
        "content": "### 9. Generating Value using LLM\n[Learn more about the Extract From File node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.extractfromfile/)\n\nPretty much identical to Step 5 bu"
      }
    },
    {
      "id": "0665fe56-48d2-4215-8d95-d4c01f9266ed",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1720,
        -140
      ]
    },
    {
      "id": "1997fb8b-73eb-4016-bab6-eb8f02fee368",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        40
      ],
      "parameters": {
        "width": 420,
        "height": 460,
        "content": "### 8. Using an Items Loop\n[Learn more about the Split in Batches node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.splitinbatches/)\n\nSimilar to Step 4, the Split in Batches nod"
      }
    },
    {
      "id": "c2799ded-b742-43a2-80ce-7a0c8f1df96e",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1540,
        500
      ]
    },
    {
      "id": "e5b42790-fc86-4134-9d04-e6bcad4a5f20",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        140
      ],
      "parameters": {
        "width": 500,
        "height": 440,
        "content": "### 10. Update the Airtable Record\n[Learn more about the Edit Fields node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/)\n\nAs with Step 6, the LLM response is used to update "
      }
    },
    {
      "id": "b1e98631-a440-4c66-b2d2-8236f6889b65",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2240,
        -1140
      ],
      "parameters": {
        "width": 300,
        "height": 120,
        "content": "[![airtable.io](https://res.cloudinary.com/daglih2g8/image/upload/f_auto,q_auto/v1/n8n-workflows/airtable_logo)](https://airtable.com/invite/r/cKzxFYVc)"
      }
    },
    {
      "id": "9d293b3a-954d-4e3b-8773-b6c3dded9520",
      "name": "Get Webhook Payload",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        -140
      ]
    },
    {
      "id": "5f8d919b-14cd-4cb4-8604-731e56cc9402",
      "name": "Parse Event",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        -140
      ]
    },
    {
      "id": "9b99d939-94d6-4fef-8b73-58c702503221",
      "name": "Get Table Schema",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -1080,
        -140
      ]
    },
    {
      "id": "c29fc911-a852-46f2-bbb1-5092cc1aaa9d",
      "name": "Fetch Records",
      "type": "n8n-nodes-base.airtable",
      "position": [
        520,
        220
      ]
    },
    {
      "id": "86d3c8d8-709f-4d9d-99bc-5d1b4aeb8603",
      "name": "Update Row",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2180,
        380
      ]
    },
    {
      "id": "95d08439-59a2-4e74-bd5a-b71cf079b621",
      "name": "Get Row",
      "type": "n8n-nodes-base.airtable",
      "position": [
        340,
        -420
      ]
    },
    {
      "id": "50888ac5-30c9-4036-aade-6ccfdf605c3b",
      "name": "Add Row ID to Payload",
      "type": "n8n-nodes-base.set",
      "position": [
        2300,
        -260
      ]
    },
    {
      "id": "e3ebeb45-45d9-44a4-a2e6-bde89f5da125",
      "name": "Update Record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2480,
        -260
      ]
    },
    {
      "id": "ac01ec4b-e030-4608-af38-64558408832f",
      "name": "Airtable Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1400,
        -140
      ]
    },
    {
      "id": "90178da9-2000-474e-ba93-a02d03ec6a1d",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1600,
        -640
      ]
    },
    {
      "id": "b8b887ce-f891-4a3c-993b-0aaccadf1b52",
      "name": "Set Airtable Vars",
      "type": "n8n-nodes-base.set",
      "position": [
        -1420,
        -640
      ]
    },
    {
      "id": "a3ef1a4a-fd22-4a37-8edb-48037f44fa4b",
      "name": "Get Table Schema1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -1240,
        -820
      ]
    },
    {
      "id": "2490bbc6-2ea1-4146-b0b8-5a406e89ea2c",
      "name": "Get \"Input\" Field",
      "type": "n8n-nodes-base.set",
      "position": [
        -1060,
        -820
      ]
    },
    {
      "id": "a3de141f-0ce8-4f8e-ae8e-f10f635d14ec",
      "name": "RecordsChanged Webhook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -880,
        -820
      ]
    },
    {
      "id": "21b0fae8-2046-4647-83c4-132d1d63503a",
      "name": "FieldsChanged Webhook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -880,
        -640
      ]
    },
    {
      "id": "f31c36cb-98da-4688-a83a-f06e46d2b8a2",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -1000
      ],
      "parameters": {
        "width": 1020,
        "height": 580,
        "content": "## ⭐️ Creating Airtable Webhooks\nTo link this workflow with Airtable, you'll have to create webhooks for the Base.\nYou'll only really need to do this this once but if these webhooks are inactive after"
      }
    }
  ],
  "connections": {
    "Get Row": {
      "main": [
        [
          {
            "node": "Filter Valid Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Row Ref": {
      "main": [
        [
          {
            "node": "Get File Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event Ref": {
      "main": [
        [
          {
            "node": "Filter Valid Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event Ref1": {
      "main": [
        [
          {
            "node": "Get Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event Type": {
      "main": [
        [
          {
            "node": "Event Ref1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Event Ref",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Event Ref",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Result": {
      "main": [
        [
          {
            "node": "Update Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Row": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Result1": {
      "main": [
        [
          {
            "node": "Add Row ID to Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Event": {
      "main": [
        [
          {
            "node": "Event Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Records": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Data": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Row Reference": {
      "main": [
        [
          {
            "node": "Get File Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Record": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Data1": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Row Reference",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable Webhook": {
      "main": [
        [
          {
            "node": "Get Table Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fields to Update": {
      "main": [
        [
          {
            "node": "Generate Field Value1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Table Schema": {
      "main": [
        [
          {
            "node": "Get Prompt Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Row Ref",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Generate Field Value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Rows": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get \"Input\" Field": {
      "main": [
        [
          {
            "node": "RecordsChanged Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Prompt Fields": {
      "main": [
        [
          {
            "node": "Get Webhook Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Table Schema1": {
      "main": [
        [
          {
            "node": "Get \"Input\" Field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Field Value1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Airtable Vars": {
      "main": [
        [
          {
            "node": "Get Table Schema1",
            "type": "main",
            "index": 0
          },
          {
            "node": "FieldsChanged Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        [
          {
            "node": "Fields to Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Field Value",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Fields": {
      "main": [
        [
          {
            "node": "Fetch Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Webhook Payload": {
      "main": [
        [
          {
            "node": "Parse Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Field Value": {
      "main": [
        [
          {
            "node": "Get Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Row ID to Payload": {
      "main": [
        [
          {
            "node": "Update Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FieldsChanged Webhook": {
      "main": [
        []
      ]
    },
    "Generate Field Value1": {
      "main": [
        [
          {
            "node": "Get Result1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RecordsChanged Webhook": {
      "main": [
        []
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Set Airtable Vars",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}