n8n workflow template · 26 nodes · OpenAI
AI Data Extraction with Dynamic Prompts and Baserow is a free n8n workflow template that starts when its webhook receives an HTTP request and works with OpenAI. It has 26 nodes, 4 of them AI nodes (Basic LLM Chain and OpenAI Chat Model). The notes inside the workflow say: “For this operation, we'll have to use the Baserow API rather than the built-in node. However, this way does allow for more flexibility with query parameters.” To run it, you add your own credentials for HTTP Header Auth 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.
Learn more about the HTTP node
For this operation, we'll have to use the Baserow API rather than the built-in node. However, this way does allow for more flexibility with query parameters.
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 Code node
We can use Baserow's List API and the HTTP node's pagination feature to fetch all applicable rows under the affected field - the filter query on the API is helpful here.
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 Baserow quicker.
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 Baserow quicker.
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 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 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 Baserow Table row - 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
This template is intended to be used as a webhook source for Baserow. Looking for a Airtable version? Click here
Join the Discord or ask in the Forum!
Baserow webhooks are created via the UI and the option can be accessed by clicking on the 3 dots button in the toolbar.
The 26 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