Reads each document you link, pulls out the details you asked for, and adds one Airtable record per document.
Uses
Airtable
OpenAI
Turn a pile of documents into an Airtable table
documentLinks to blank.Set documentLinks to blank.detailsToPullOut to blank.Set detailsToPullOut to blank.airtableBaseId to blank.Set airtableBaseId to blank.airtableTableName to blank.Set airtableTableName to blank.maxDocuments to 25.Set maxDocuments to 25.airtableBaseId and save it as baseId.Trim airtableBaseId and save it as baseId.airtableTableName and save it as tableName.Trim airtableTableName and save it as tableName.detailFieldNames to an empty list.Set detailFieldNames to an empty list.detailEntry in detailsToPullOut with "For each detailEntry in detailsToPullOut with
replaced by , split by ,:detailEntry and save it as detailName.Trim detailEntry and save it as detailName.detailName isn't emptyIf detailName isn't emptyYes
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
detailFieldNames is emptyIf detailFieldNames is emptyYes
No
No steps
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.addedOn.Get today's date and save it as addedOn.documentsRead to 0.Set documentsRead to 0.filedCount to 0.Set filedCount to 0.skippedCount to 0.Set skippedCount to 0.failedCount to 0.Set failedCount to 0.documentEntry in documentLinks with "For each documentEntry in documentLinks with
replaced by , split by ,:documentsRead is greater than or equal to maxDocumentsIf documentsRead is greater than or equal to maxDocumentsYes
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.No
No steps
documentEntry and save it as documentLink.Trim documentEntry and save it as documentLink.documentLink isn't emptyIf documentLink isn't emptyYes
documentsRead.Add 1 to documentsRead.documentLink starts with http (ignoring case) or documentLink starts with…If documentLink starts with http (ignoring case) or documentLink starts with…Yes
documentErrorIf a step below fails, save the error as documentErrorTry
tableName. Save it as alreadyFiled.List records in tableName. Save it as alreadyFiled.alreadyFiled.records isn't emptyIf alreadyFiled.records isn't emptyYes
skippedCount.Add 1 to skippedCount.documentLink.Show in the output: Already in the table, left alone: documentLink.No
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.extractedFields to extraction.output.fields.Set extractedFields to extraction.output.fields.documentTitle to blank.Set documentTitle to blank.documentType to blank.Set documentType to blank.detailLines to an empty list.Set detailLines to an empty list.extractedField in extractedFields:For each extractedField in extractedFields:extractedField.name and save it as fieldName. Trim extractedField.name and save it as fieldName.fieldValue to blank. Set fieldValue to blank.fieldIsAList If a step below fails, save the error as fieldIsAListTry
extractedField.value and save it as fieldValue.Trim extractedField.value and save it as fieldValue.On error
extractedField.value with , and save it as fieldValue.Join extractedField.value with , and save it as fieldValue.fieldName is Title If fieldName is TitleYes
documentTitle to fieldValue.Change documentTitle to fieldValue.No
No steps
fieldName is Document Type If fieldName is Document TypeYes
documentType to fieldValue.Change documentType to fieldValue.No
No steps
Title, Document Type] doesn't contain fieldName If [Title, Document Type] doesn't contain fieldNameYes
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
recordTitle to documentTitle.Set recordTitle to documentTitle.recordTitle is emptyIf recordTitle is emptyYes
recordTitle to documentLink.Change recordTitle to documentLink.No
No steps
tableName.Add a record to tableName.filedCount.Add 1 to filedCount.On error
failedCount.Add 1 to failedCount.documentLink: documentError.message.Show in the output: Could not file documentLink: documentError.message.No
failedCount.Add 1 to failedCount.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
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.runSummary.Show in the output: runSummary.filedCount is 0 and failedCount is greater than 0If filedCount is 0 and failedCount is greater than 0Yes
No
No steps