Checks a Box folder hourly and gives each new PDF its own summary document and one row in your index sheet.

UsesClaudeBoxGoogle DocsGoogle Sheets

Summarise and index new documents in a Box folder

ScheduleRun every hour.Run every hour.
ValuesSet boxFolderId to blank.Set boxFolderId to blank.
ValuesSet indexSpreadsheetUrl to blank.Set indexSpreadsheetUrl to blank.
ValuesSet indexSheetTabName to blank.Set indexSheetTabName to blank.
ValuesSet maxDocumentsPerRun to 10.Set maxDocumentsPerRun to 10.
TextTrim boxFolderId and save it as folderId.Trim boxFolderId and save it as folderId.
TextTrim indexSpreadsheetUrl and save it as spreadsheetUrl.Trim indexSpreadsheetUrl and save it as spreadsheetUrl.
TextTrim indexSheetTabName and save it as sheetName.Trim indexSheetTabName and save it as sheetName.
MathSet documentCap to maxDocumentsPerRun multiplied by 1.Set documentCap to maxDocumentsPerRun multiplied by 1.
Decisions & LoopsIf documentCap is greater than or equal to 1 is no or documentCap is less than or…If documentCap is greater than or equal to 1 is no or documentCap is less than or…
Yes
Decisions & LoopsStop and report a problem: The 'maxDocumentsPerRun' step has to be a whole number between 1 and 100. It is how many documents one run will read.Stop and report a problem: The 'maxDocumentsPerRun' step has to be a whole number between 1 and 100. It is how many documents one run will read.
No
No steps
ValuesSet alreadySummarised to an empty list.Set alreadySummarised to an empty list.
Decisions & LoopsIf a step below fails, save the error as ledgerErrorIf a step below fails, save the error as ledgerError
Try
Google SheetsGoogle SheetsRead column 'C' of sheetName in spreadsheetUrl. Save it as ledger.Read column 'C' of sheetName in spreadsheetUrl. Save it as ledger.
Decisions & LoopsFor each ledgerValue in ledger.values:For each ledgerValue in ledger.values:
Text Trim ledgerValue and save it as seenId. Trim ledgerValue and save it as seenId.
Decisions & Loops If seenId isn't empty and seenId is not null If seenId isn't empty and seenId is not null
Yes
ListsAdd seenId to the end of alreadySummarised and save it as alreadySummarised.Add seenId to the end of alreadySummarised and save it as alreadySummarised.
No
No steps
On error
Decisions & LoopsStop and report a problem: Could not read column C of the index sheet, which is the only record of what has already been read - so nothing has been touched. Check the 'indexSpreadsheetUrl' and 'indexSheetTabName' steps. The reason given was: ledgerError.message.Stop and report a problem: Could not read column C of the index sheet, which is the only record of what has already been read - so nothing has been touched. Check the 'indexSpreadsheetUrl' and 'indexSheetTabName' steps. The reason given was: ledgerError.message.
ValuesSet folderItems to an empty list.Set folderItems to an empty list.
Decisions & LoopsIf a step below fails, save the error as folderErrorIf a step below fails, save the error as folderError
Try
BoxBoxList items in Box folder folderId. Save it as folder.List items in Box folder folderId. Save it as folder.
ValuesChange folderItems to folder.items.Change folderItems to folder.items.
On error
Decisions & LoopsStop and report a problem: Could not list that Box folder, so nothing has been read. Check the id in the 'boxFolderId' step. The reason given was: folderError.message.Stop and report a problem: Could not list that Box folder, so nothing has been read. Check the id in the 'boxFolderId' step. The reason given was: folderError.message.
ValuesSet summarisedCount to 0.Set summarisedCount to 0.
ValuesSet alreadyDoneCount to 0.Set alreadyDoneCount to 0.
ValuesSet notADocumentCount to 0.Set notADocumentCount to 0.
ValuesSet failedCount to 0.Set failedCount to 0.
TextTrim today's date and save it as readOn.Trim today's date and save it as readOn.
Decisions & LoopsFor each item in folderItems:For each item in folderItems:
Decisions & LoopsIf summarisedCount is greater than or equal to documentCapIf summarisedCount is greater than or equal to documentCap
Yes
ValuesShow in the output: Stopped after summarisedCount document(s). The rest of the folder is picked up on the next run.Show in the output: Stopped after summarisedCount document(s). The rest of the folder is picked up on the next run.
Decisions & LoopsStop repeating.Stop repeating.
No
No steps
ValuesSet itemType to blank.Set itemType to blank.
Decisions & LoopsIf a step below fails, save the error as itemTypeErrorIf a step below fails, save the error as itemTypeError
Try
TextTrim item.type and save it as itemType.Trim item.type and save it as itemType.
On error
ValuesChange itemType to blank.Change itemType to blank.
Decisions & LoopsIf itemType is not fileIf itemType is not file
Yes
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
ValuesSet fileName to blank.Set fileName to blank.
Decisions & LoopsIf a step below fails, save the error as fileNameErrorIf a step below fails, save the error as fileNameError
Try
TextTrim item.name and save it as fileName.Trim item.name and save it as fileName.
On error
ValuesChange fileName to blank.Change fileName to blank.
TextTrim item.id and save it as fileId.Trim item.id and save it as fileId.
Decisions & LoopsIf fileName is empty or fileId is empty or fileId is nullIf fileName is empty or fileId is empty or fileId is null
Yes
ValuesShow in the output: Skipped an item in the folder because Box gave it no usable name or id..Show in the output: Skipped an item in the folder because Box gave it no usable name or id..
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf alreadySummarised contains fileIdIf alreadySummarised contains fileId
Yes
ValuesAdd 1 to alreadyDoneCount.Add 1 to alreadyDoneCount.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf fileName doesn't end with .pdf (ignoring case)If fileName doesn't end with .pdf (ignoring case)
Yes
ValuesAdd 1 to notADocumentCount.Add 1 to notADocumentCount.
ValuesShow in the output: Left alone because it is not a PDF: fileName.Show in the output: Left alone because it is not a PDF: fileName.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf a step below fails, save the error as documentErrorIf a step below fails, save the error as documentError
Try
BoxBoxDownload file fileId. Save it as download.Download file fileId. Save it as download.
TextTrim download.document_ref and save it as documentRef.Trim download.document_ref and save it as documentRef.
AI AgentRun an AI agent: Read the attached document and pull out each of these fields, in this order: - Document t… and save it as extraction.Run an AI agent: Read the attached document and pull out each of these fields, in this order: - Document t… and save it as extraction.
ValuesSet detailLines to an empty list.Set detailLines to an empty list.
ValuesSet documentTitle to blank.Set documentTitle to blank.
Decisions & LoopsFor each extractedField in extraction.output.fields:For each extractedField in extraction.output.fields:
Values Set fieldName to blank. Set fieldName to blank.
Decisions & Loops If a step below fails, save the error as fieldNameError If a step below fails, save the error as fieldNameError
Try
TextTrim extractedField.name and save it as fieldName.Trim extractedField.name and save it as fieldName.
On error
ValuesChange fieldName to blank.Change fieldName to blank.
Decisions & Loops If fieldName isn't empty If fieldName isn't empty
Yes
ValuesSet fieldValue to blank.Set fieldValue to blank.
Decisions & LoopsIf a step below fails, save the error as fieldValueErrorIf a step below fails, save the error as fieldValueError
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 & LoopsIf fieldValue isn't emptyIf fieldValue isn't empty
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.
Decisions & LoopsIf fieldName is Document titleIf fieldName is Document title
Yes
ValuesChange documentTitle to fieldValue.Change documentTitle to fieldValue.
No
No steps
No
No steps
No
No steps
TextJoin detailLines with a new line and save it as detailBlock.Join detailLines with a new line and save it as detailBlock.
Decisions & LoopsIf detailBlock is emptyIf detailBlock is empty
Yes
ValuesAdd 1 to failedCount.Add 1 to failedCount.
ValuesShow in the output: Nothing could be read out of fileName, so it has been left for you to look at. Nothing was written.Show in the output: Nothing could be read out of fileName, so it has been left for you to look at. Nothing was written.
No
ValuesSet summaryText to blank.Set summaryText to blank.
Decisions & LoopsIf a step below fails, save the error as summaryErrorIf a step below fails, save the error as summaryError
Try
ClaudeClaudeAsk Claude: 'Below are details read word for word out of one document. Write a short note for someone filing it.Ask Claude: 'Below are details read word for word out of one document. Write a short note for someone filing it. Rules: use only the details below. Do not add anything they do not contain, and do not guess at a detail that came back blank. Do not describe the document as good, bad, urgent or routine - you have not read all of it. Write the first line as one sentence saying what this document is. Then a blank line. Then up to five short lines covering who it involves, what it concerns and any dates or amounts it states. Plain text only. DETAILS READ FROM THE DOCUMENT: detailBlock'. Save it as summaryReply. Maximum response length: 700
TextTrim summaryReply.response_text and save it as summaryText.Trim summaryReply.response_text and save it as summaryText.
On error
ValuesChange summaryText to blank.Change summaryText to blank.
Decisions & LoopsIf summaryText is emptyIf summaryText is empty
Yes
ValuesChange summaryText to No written note came back for this document. The details read out of it are below, unchanged..Change summaryText to No written note came back for this document. The details read out of it are below, unchanged..
No
No steps
TextTrim the first item of summaryText split by a new line and save it as headline.Trim the first item of summaryText split by a new line and save it as headline.
ValuesSet documentName to documentTitle.Set documentName to documentTitle.
Decisions & LoopsIf documentName is emptyIf documentName is empty
Yes
ValuesChange documentName to fileName.Change documentName to fileName.
No
No steps
Decisions & LoopsIf headline is emptyIf headline is empty
Yes
ValuesChange headline to documentName.Change headline to documentName.
No
No steps
TextTrim the document id from the Google Docs “Create document” step and save it as summaryDocumentId.Trim the document id from the Google Docs “Create document” step and save it as summaryDocumentId.
Google DocsGoogle DocsAdd the heading documentName to summaryDocumentId.Add the heading documentName to summaryDocumentId.
Google DocsGoogle DocsAdd text to summaryDocumentId.Add text to summaryDocumentId.summaryText Read word for word from the document: detailBlock Source file: fileName (Box file fileId), read on readOn.
Google SheetsGoogle SheetsAdd a row to sheetName in spreadsheetUrl.Add a row to sheetName in spreadsheetUrl.
ValuesAdd 1 to summarisedCount.Add 1 to summarisedCount.
On error
ValuesAdd 1 to failedCount.Add 1 to failedCount.
ValuesShow in the output: Could not read fileName, so it has been left alone and will be tried again next run: documentError.message.Show in the output: Could not read fileName, so it has been left alone and will be tried again next run: documentError.message.
ValuesShow in the output: Read and indexed summarisedCount new document(s). Already indexed: alreadyDoneCount. Not a PDF: notADocumentCount. Could not be read: failedCount.Show in the output: Read and indexed summarisedCount new document(s). Already indexed: alreadyDoneCount. Not a PDF: notADocumentCount. Could not be read: failedCount.