n8n workflow template · 32 nodes · OpenAI
AI Data Extraction with Dynamic Prompts and Airtable is a free n8n workflow template that starts when its webhook receives an HTTP request and works with OpenAI and Airtable. It has 32 nodes, 4 of them AI nodes (Basic LLM Chain and OpenAI Chat Model). The notes inside the workflow say: “To link this workflow with Airtable, you'll have to create webhooks for the Base. You'll only really need to do this this once but if these webhooks are inactive after 7 days, you'll need to create them again.” To run it, you add your own credentials for Airtable API and OpenAI API.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
To link this workflow with Airtable, you'll have to create webhooks for the Base. You'll only really need to do this this once but if these webhooks are inactive after 7 days, you'll need to create them again.
Check out the Airtable Developer documentation for more info
Learn more about the Airtable node
For this operation, we'll use the handy Airtable node. I recommend getting familiar with this node for all your Airtable needs!
Learn more about the Switch node
A simple switch node can be used to determine which event to handle. The difference between our row and field events is that row event affect a single row whereas field events affect all rows.
This 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!
This branch updates only the rows impacted.
Learn more about the Split Out node
This step handles one or more updated rows where "updated" means the "input" column (ie. "file" in our example) for these rows were changed. For each affected row, we'll get the full row to figure out only the columns we need to update - this is an optimisation to avoid redundant work ie. generating values for columns which already have a value.
Learn more about the Filter node
To keep things performant, we can decide to get only rows with inputfield populated as this is required to perform the extraction. This can easily be achieved with Airtable filters.
Learn more about the Split in Batches node
Similar to Step 4, the Split in Batches node is a preference for user experience - changes are seen in the Airtable quicker.
Learn more about the Split in Batches node
A split in batches node is used here to update a row at a time however, this is a preference for user experience - changes are seen in the Airtable quicker.
Learn more about the Extract From File node
Pretty much identical to Step 5 but instead of updating every field/column, we only need to generate a value for one.
Learn more about the Basic LLM node
This step is where it all comes together! In short, we give our LLM the PDF contents as the context and loop through our dynamic prompts (from the schema we pulled earlier) for our row. At the end, our LLM should have produced a value for each column requested.
Note: There's definitely a optimisation which could be done for caching PDFs but it beyond the scope of this demonstration.
Learn more about the Edit Fields node
As with Step 6, the LLM response is used to update the row however only under the field that was created/changed. Once complete, the loop continues and the next row is processed.
Learn more about the Edit Fields node
Finally, we can collect the LLM responses and combine them to build an API request to update our Airtable record - the Id of which we got from initial webhook. After this is done, we can move onto the next row and repeat the process.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
Check out the video demo I did for n8n Studio
Check out the example Airtable here
This template is intended to be used as a webhook source for Airtable. Looking for a Baserow version? Click here
Join the Discord or ask in the Forum!
The 32 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
Do you need somewhere to run it? Read our guide to self-hosted n8n.
We can adapt this workflow to your apps, data and process, then deploy and support it.
Contact Us