Reads each document you link, pulls out the details you asked for, and adds one Airtable record per document.

UsesAirtableOpenAI

Turn a pile of documents into an Airtable table

Give it a list of links to PDFs or images, say which details you want out of each one, and run it whenever you have a pile to file. Each document is read as written, the details you named are pulled out, and one record is added to your Airtable table per document.

Each record holds the link, a title, the document type, the details you asked for as one line each, and the date it was added. Before anything is written the link is looked up in the table, so a document already there is left exactly as it is and a re-run files only new links. Nothing is overwritten or deleted. A document that cannot be read is reported and skipped rather than stopping the run, each run takes a capped number of documents, and if nothing could be filed the run stops with a message.

Your table needs five columns before the first run: 'Document', 'Title', 'Document Type', 'Details' and 'Added'. Links have to serve the file itself rather than a preview page; uploaded files work too.

ValuesSet documentLinks to blank.Set documentLinks to blank.
ValuesSet detailsToPullOut to blank.Set detailsToPullOut to blank.
ValuesSet airtableBaseId to blank.Set airtableBaseId to blank.
ValuesSet airtableTableName to blank.Set airtableTableName to blank.
ValuesSet maxDocuments to 25.Set maxDocuments to 25.
TextTrim airtableBaseId and save it as baseId.Trim airtableBaseId and save it as baseId.
TextTrim airtableTableName and save it as tableName.Trim airtableTableName and save it as tableName.
ValuesSet detailFieldNames to an empty list.Set detailFieldNames to an empty list.
Decisions & LoopsFor each detailEntry in detailsToPullOut with "For each detailEntry in detailsToPullOut with replaced by , split by ,:
TextTrim detailEntry and save it as detailName.Trim detailEntry and save it as detailName.
Decisions & LoopsIf detailName isn't emptyIf detailName isn't empty
Yes
ListsAdd detailName to the end of detailFieldNames and save it as detailFieldNames.Add detailName to the end of detailFieldNames and save it as detailFieldNames.
No
No steps
Decisions & LoopsIf detailFieldNames is emptyIf detailFieldNames is empty
Yes
Decisions & LoopsStop and report a problem: The 'detailsToPullOut' step has no field names in it. Write the details you want out of each document separated by commas - for example 'Supplier, Effective date, Contract value' - then run it again.Stop and report a problem: The 'detailsToPullOut' step has no field names in it. Write the details you want out of each document separated by commas - for example 'Supplier, Effective date, Contract value' - then run it again.
No
No steps
ListsCombine [Title, Document Type] and detailFieldNames into one list and save it as fieldsToExtract.Combine [Title, Document Type] and detailFieldNames into one list and save it as fieldsToExtract.
Dates & TimesGet today's date and save it as addedOn.Get today's date and save it as addedOn.
ValuesSet documentsRead to 0.Set documentsRead to 0.
ValuesSet filedCount to 0.Set filedCount to 0.
ValuesSet skippedCount to 0.Set skippedCount to 0.
ValuesSet failedCount to 0.Set failedCount to 0.
Decisions & LoopsFor each documentEntry in documentLinks with "For each documentEntry in documentLinks with replaced by , split by ,:
Decisions & LoopsIf documentsRead is greater than or equal to maxDocumentsIf documentsRead is greater than or equal to maxDocuments
Yes
ValuesShow in the output: Stopped after documentsRead documents. Raise the 'maxDocuments' step to take more in one run.Show in the output: Stopped after documentsRead documents. Raise the 'maxDocuments' step to take more in one run.
Decisions & LoopsStop repeating.Stop repeating.
No
No steps
TextTrim documentEntry and save it as documentLink.Trim documentEntry and save it as documentLink.
Decisions & LoopsIf documentLink isn't emptyIf documentLink isn't empty
Yes
ValuesAdd 1 to documentsRead.Add 1 to documentsRead.
Decisions & LoopsIf documentLink starts with http (ignoring case) or documentLink starts with…If documentLink starts with http (ignoring case) or documentLink starts with…
Yes
Decisions & LoopsIf a step below fails, save the error as documentErrorIf a step below fails, save the error as documentError
Try
AirtableAirtableList records in tableName. Save it as alreadyFiled.List records in tableName. Save it as alreadyFiled.
Decisions & LoopsIf alreadyFiled.records isn't emptyIf alreadyFiled.records isn't empty
Yes
ValuesAdd 1 to skippedCount.Add 1 to skippedCount.
ValuesShow in the output: Already in the table, left alone: documentLink.Show in the output: Already in the table, left alone: documentLink.
No
AI AgentRun an AI agent: Read the attached document and pull out each of these fields, in this order: - fieldsToE… and save it as extraction.Run an AI agent: Read the attached document and pull out each of these fields, in this order: - fieldsToE… and save it as extraction.
ValuesSet extractedFields to extraction.output.fields.Set extractedFields to extraction.output.fields.
ValuesSet documentTitle to blank.Set documentTitle to blank.
ValuesSet documentType to blank.Set documentType to blank.
ValuesSet detailLines to an empty list.Set detailLines to an empty list.
Decisions & LoopsFor each extractedField in extractedFields:For each extractedField in extractedFields:
Text Trim extractedField.name and save it as fieldName. Trim extractedField.name and save it as fieldName.
Values Set fieldValue to blank. Set fieldValue to blank.
Decisions & Loops If a step below fails, save the error as fieldIsAList If a step below fails, save the error as fieldIsAList
Try
TextTrim extractedField.value and save it as fieldValue.Trim extractedField.value and save it as fieldValue.
On error
TextJoin extractedField.value with , and save it as fieldValue.Join extractedField.value with , and save it as fieldValue.
Decisions & Loops If fieldName is Title If fieldName is Title
Yes
ValuesChange documentTitle to fieldValue.Change documentTitle to fieldValue.
No
No steps
Decisions & Loops If fieldName is Document Type If fieldName is Document Type
Yes
ValuesChange documentType to fieldValue.Change documentType to fieldValue.
No
No steps
Decisions & Loops If [Title, Document Type] doesn't contain fieldName If [Title, Document Type] doesn't contain fieldName
Yes
ListsAdd fieldName: fieldValue to the end of detailLines and save it as detailLines.Add fieldName: fieldValue to the end of detailLines and save it as detailLines.
No
No steps
ValuesSet recordTitle to documentTitle.Set recordTitle to documentTitle.
Decisions & LoopsIf recordTitle is emptyIf recordTitle is empty
Yes
ValuesChange recordTitle to documentLink.Change recordTitle to documentLink.
No
No steps
AirtableAirtableAdd a record to tableName.Add a record to tableName.
ValuesAdd 1 to filedCount.Add 1 to filedCount.
On error
ValuesAdd 1 to failedCount.Add 1 to failedCount.
ValuesShow in the output: Could not file documentLink: documentError.message.Show in the output: Could not file documentLink: documentError.message.
No
ValuesAdd 1 to failedCount.Add 1 to failedCount.
ValuesShow in the output: Skipped documentLink - a document has to be a direct link to a PDF or image file starting with http, or an uploaded file reference starting with doc_, and cannot contain a double quote.Show in the output: Skipped documentLink - a document has to be a direct link to a PDF or image file starting with http, or an uploaded file reference starting with doc_, and cannot contain a double quote.
No
No steps
ValuesSet runSummary to Filed filedCount new document(s). Already in the table: skippedCount. Could not be read: failedCount.Set runSummary to Filed filedCount new document(s). Already in the table: skippedCount. Could not be read: failedCount.
ValuesShow in the output: runSummary.Show in the output: runSummary.
Decisions & LoopsIf filedCount is 0 and failedCount is greater than 0If filedCount is 0 and failedCount is greater than 0
Yes
Decisions & LoopsStop and report a problem: No documents were filed and at least one could not be read. Check that the table has the columns Document, Title, Document Type, Details and Added, that your Airtable token can write to this base, and that each link serves the PDF or image itself rather than a preview page.Stop and report a problem: No documents were filed and at least one could not be read. Check that the table has the columns Document, Title, Document Type, Details and Added, that your Airtable token can write to this base, and that each link serves the PDF or image itself rather than a preview page.
No
No steps