Reads each Google Doc you list, summarises it with AI, and appends every summary to one digest document.
Uses
Google Docs
OpenAI
Summarise a batch of documents into one digest
Give it a list of Google Docs links and one Google Doc to collect the results in, then run it whenever you have a batch to get through. Each document is read in turn, summarised by the AI following your own instructions, and added to the digest under its source link.
You end up with a dated block in the digest holding one summary per document, each followed by the link it came from. Every run adds a new block rather than replacing what is already there, so the digest becomes a running record you can search later, and summaries use only what each document says. A document that cannot be opened, whether a bad link, a file the connected account cannot reach or an empty page, is listed at the bottom under 'Could not be read' and the rest of the batch still goes through, so one broken link never costs you the whole run. Only Google Docs have text to read, so PDFs, spreadsheets and images land on that list too.
documentLinks to blank.Set documentLinks to blank.digestDocumentLink to blank.Set digestDocumentLink to blank.summaryInstructions to Give at most three bullet points covering what the document is for and what it decides or asks for, then a final line starting 'Follow-ups:' naming any owners, dates or open questions it mentions..Set summaryInstructions to Give at most three bullet points covering what the document is for and what it decides or asks for, then a final line starting 'Follow-ups:' naming any owners, dates or open questions it mentions..maxCharactersPerDocument to 12000.Set maxCharactersPerDocument to 12000.digestDocumentLink starts with httpIf digestDocumentLink starts with httpdigestDocumentLink doesn't contain /d/If digestDocumentLink doesn't contain /d/digestDocumentLink split by /d/ and save it as digestLinkTail.Get the last item of digestDocumentLink split by /d/ and save it as digestLinkTail.digestLinkTail split by / and save it as digestDocumentId.Get the first item of digestLinkTail split by / and save it as digestDocumentId.digestDocumentId is emptyIf digestDocumentId is emptydocumentLinks by a new line and save it as documentList.Split documentLinks by a new line and save it as documentList.summaries to an empty list.Set summaries to an empty list.skipped to an empty list.Set skipped to an empty list.link in documentList:For each link in documentList:link and save it as documentLink.Trim link and save it as documentLink.documentLink is emptyIf documentLink is emptydocumentLink starts with httpIf documentLink starts with httpdocumentLink doesn't contain /d/If documentLink doesn't contain /d/documentLink to the end of skipped and save it as skipped.Add documentLink to the end of skipped and save it as skipped.documentLink split by /d/ and save it as linkTail.Get the last item of documentLink split by /d/ and save it as linkTail.linkTail split by / and save it as documentId.Get the first item of linkTail split by / and save it as documentId.documentId is emptyIf documentId is emptydocumentLink to the end of skipped and save it as skipped.Add documentLink to the end of skipped and save it as skipped.documentText to blank.Set documentText to blank.readErrorIf a step below fails, save the error as readErrordocumentId. Save it as document.Read documentId. Save it as document.document.text and save it as documentText.Trim document.text and save it as documentText.documentLink: readError as text.Show in the output: Could not read documentLink: readError as text.documentText is emptyIf documentText is emptydocumentLink to the end of skipped and save it as skipped.Add documentLink to the end of skipped and save it as skipped.prompt to You are summarising one document for a colleague who has not read it. Use only what the document says, and do not invent anything it does not contain.Set prompt to You are summarising one document for a colleague who has not read it. Use only what the document says, and do not invent anything it does not contain.
summaryInstructions
Start your answer with a single line naming the document, then the summary.
Document link: documentLink
Document text:
documentText truncated to maxCharactersPerDocument characters.summary to blank.Set summary to blank.summaryErrorIf a step below fails, save the error as summaryErrorprompt. Save it as modelReply.Ask OpenAI: prompt. Save it as modelReply.modelReply.response_text and save it as summary.Trim modelReply.response_text and save it as summary.documentLink: summaryError as text.Show in the output: Could not summarise documentLink: summaryError as text.summary is emptyIf summary is emptydocumentLink to the end of skipped and save it as skipped.Add documentLink to the end of skipped and save it as skipped.summaryAdd summary
Source: documentLink to the end of summaries and save it as summaries.summaries is emptyIf summaries is emptydigest to Document summaries - today's dateSet digest to Document summaries - today's date
summaries joined by a blank line.skipped isn't emptyIf skipped isn't emptydigest to digestChange digest to digest
Could not be read: skipped joined by , .digestDocumentId.Add text to digestDocumentId.digestsummaries as text document summaries to the digest.Show in the output: Added the length of summaries as text document summaries to the digest.