← All N8N workflows
AI & researchAirtableChain LLMCodeExtract From FileFilter

ai data extraction with dynamic prompts and baserow

Configured with Airtable, Chain LLM, Extract From File, Filter, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
RoutingEvent TypeSwitchCodeGet Prompt FieldsCodeWeb / APIGet File DataHTTP RequestTransformExtract from FileExtract From FileTransformGet ResultEdit FieldsRoutingLoop Over ItemsLoop Over ItemsRoutingRow ReferenceNo OpAI & modelsGenerate Field ValueChain LLMCodeFields to UpdateCodeRoutingLoop Over Items1Loop Over ItemsRoutingRow RefNo OpWeb / APIGet File Data1HTTP RequestTransformExtract from File1Extract From FileTransformGet Result1Edit FieldsAI & modelsGenerate Field Value1Chain LLMRoutingFilter Valid RowsFilterRoutingFilter Valid FieldsFilterRoutingEvent RefNo OpRoutingEvent Ref1No OpAI & modelsOpenAI Chat ModelOpenAI Chat ModelAI & modelsOpenAI Chat Model1OpenAI Chat ModelWeb / APIGet Webhook PayloadHTTP RequestCodeParse EventCodeData storeGet Table SchemaAirtableData storeFetch RecordsAirtableData storeUpdate RowAirtableData storeGet RowAirtableTransformAdd Row ID to PayloadEdit FieldsData storeUpdate RecordAirtableTriggerAirtable WebhookWebhookTriggerWhen clicking ‘Testworkflow’Manual TriggerTransformSet Airtable VarsEdit FieldsData storeGet Table Schema1AirtableTransformGet "Input" FieldEdit FieldsWeb / APIRecordsChanged WebhookHTTP RequestWeb / APIFieldsChanged WebhookHTTP Request

Node categories in this workflow

  • Routing
  • Code
  • Web / API
  • Transform
  • AI & models
  • Data store
  • Trigger

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Event TypeRoutingSwitchSee node parameters
Get Prompt FieldsCodeCodeSee node parameters
Get File DataWeb / APIHTTP RequestSee node parameters
Extract from FileTransformExtract From Filepdf
Get ResultTransformEdit FieldsSee node parameters
Loop Over ItemsRoutingLoop Over ItemsSee node parameters
Row ReferenceRoutingNo OpSee node parameters
Generate Field ValueAI & modelsChain LLMSee node parameters
Fields to UpdateCodeCodeSee node parameters
Loop Over Items1RoutingLoop Over ItemsSee node parameters
Row RefRoutingNo OpSee node parameters
Get File Data1Web / APIHTTP RequestSee node parameters
Extract from File1TransformExtract From Filepdf
Get Result1TransformEdit FieldsSee node parameters
Generate Field Value1AI & modelsChain LLMSee node parameters
Filter Valid RowsRoutingFilterSee node parameters
Filter Valid FieldsRoutingFilterSee node parameters
Event RefRoutingNo OpSee node parameters
Event Ref1RoutingNo OpSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
OpenAI Chat Model1AI & modelsOpenAI Chat ModelSee node parameters
Get Webhook PayloadWeb / APIHTTP RequestSee node parameters
Parse EventCodeCodeSee node parameters
Get Table SchemaData storeAirtablebase / getSchema
Fetch RecordsData storeAirtablesearch
Update RowData storeAirtableupdate
Get RowData storeAirtableSee node parameters
Add Row ID to PayloadTransformEdit FieldsSee node parameters
Update RecordData storeAirtableupdate
Airtable WebhookTriggerWebhookSee node parameters
When clicking ‘Test workflow’TriggerManual TriggerSee node parameters
Set Airtable VarsTransformEdit FieldsSee node parameters
Get Table Schema1Data storeAirtablebase / getSchema
Get "Input" FieldTransformEdit FieldsSee node parameters
RecordsChanged WebhookWeb / APIHTTP RequestPOST
FieldsChanged WebhookWeb / APIHTTP RequestPOST

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • airtableTokenApi
  • openAiApi

Workflow notes

1. Get Table Schema

1. Get Table Schema

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!

2a. Updates Minimal Number of Rows

2a. Updates Minimal Number of Rows

This branch updates only the rows impacted.

2b. Update Every Row under the Field

2b. Update Every Row under the Field

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!

Try It Out!

Try It Out!

This n8n template powers a "dynamic" or "user-defined" prompts with PDF workflow pattern for a Airtable table. Simply put, it allows users to populate a spreadsheet using prompts without touching the underlying template.

Check out the video demo I did for n8n Studio: https://www.youtube.com/watch?v=_fNAD1u8BZw

Check out the example Airtable here: https://airtable.com/appAyH3GCBJ56cfXl/shrXzR1Tj99kuQbyL

This template is intended to be used as a webhook source for Airtable. Looking for a Baserow version? Click here

How it works

  • Each Airtable.io tables offers integration feature whereby changes to the table can be sent as events to any accessible webhook. This allows for a reactive trigger pattern which makes this type of workflow possible. For our usecase, we capture the vents of row_updated, field_created and field_updated.
  • Next, we'll need an "input" column in our Airtable.io table. This column will be where our context lives for evaluating the prompts against. In this example, our "input" column name is "file" and it's where we'll upload our PDFs. Note, this "input" field is human-controlled and never updated from this template.
  • Now for the columns (aka "fields" in Airtable). Each field allows us to define a name, type and description and together form the schema. The first 2 are self-explaintory but the "description" will be for users to provide their prompts ie. what data should the field to contain.
  • In this template, a webhook trigger waits for when a row or column is updated. The incoming event comes with lots of details such as the table, row and/or column Ids that were impacted.
  • We use this information to fetch the table's schema in order to get the column's descriptions (aka dynamic prompts).
  • For each triggered event, we download our input ie. the PDF and ready it for our AI/LLM. By iterating through the available columns and feeding the dynamic prompts, our LLM can run those prompts against the PDF and thus generating a value response for each cell.
  • These values are then collected and used to update the Airtable Record.

How to use

  • You'll need to publish this workflow and make it accessible to our Airtable instance.
  • you must run the "Create Airtable Webhooks" mini-flow to link it to your Airtable.
  • This template is reusable for other Airtables but the webhooks need to be created each time for each table.

Need Help?

Join the Discord or ask in the Forum!

Happy Flowgramming!

2. Event Router Pattern

2. Event Router Pattern

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.

3. Filter Only Rows with Valid Input

3. Filter Only Rows with Valid Input

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.

6. Update the Airtable Record

6. Update the Airtable Record

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.

5. PDFs, LLMs and Dynamic Prompts? Oh My!

5. PDFs, LLMs and Dynamic Prompts? Oh My!

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.

4. Using an Items Loop

4. Using an Items Loop

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.

7. Listing All Applicable Rows Under The Column

7. Listing All Applicable Rows Under The Column

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.

9. Generating Value using LLM

9. Generating Value using LLM

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.

8. Using an Items Loop

8. Using an Items Loop

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.

10. Update the Airtable Record

10. Update the Airtable Record

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.

Sticky Note6

⭐️ Creating Airtable Webhooks

⭐️ Creating Airtable Webhooks

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: https://airtable.com/developers/web/api/webhooks-overview

ai data extraction with dynamic prompts and baserow

ai data extraction with dynamic prompts and baserow

Purpose and structure

This folder contains the ai data extraction with dynamic prompts and baserow workflow. Its executable nodes use airtable, chainLlm, code, extractFromFile, filter, httpRequest, lmChatOpenAi, manualTrigger, noOp, set, splitInBatches, switch, webhook. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Airtable Webhook, When clicking ‘Test workflow’

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0696_Code_Webhook_Create_Webhook.json MIT; preserve source notices.

More in AI & research