Reads the mail that arrived in the window you set and emails you one digest of what matters and what needs doing.
Uses
Gmail
OpenAI
Inbox digest with your next actions
digestTo to blank.Set digestTo to blank.digestTitle to Morning inbox digest.Set digestTitle to Morning inbox digest.mailWindow to newer_than:1d.Set mailWindow to newer_than:1d.windowLabel to since this time yesterday.Set windowLabel to since this time yesterday.maxEmails to 40.Set maxEmails to 40.mailWindow. Save it as mail.List emails matching mailWindow. Save it as mail.messages to mail.emails.Set messages to mail.emails.lines to an empty list.Set lines to an empty list.skipped to 0.Set skipped to 0.email in messages:For each email in messages:unreadableIf a step below fails, save the error as unreadableTry
email.from and save it as sender.Trim email.from and save it as sender.email.subject and save it as subject.Trim email.subject and save it as subject.email.snippet and save it as preview.Trim email.snippet and save it as preview.sender | subject | preview to the end of lines and save it as lines.Add - From sender | subject | preview to the end of lines and save it as lines.On error
skipped.Add 1 to skipped.unreadable as text.Show in the output: Left a message out of the digest: unreadable as text.lines and save it as mailCount.Count the items in lines and save it as mailCount.lines with a new line and save it as mailList.Join lines with a new line and save it as mailList.subjectLine to blank.Set subjectLine to blank.digestBody to blank.Set digestBody to blank.mailCount is 0If mailCount is 0Yes
subjectLine to digestTitle - nothing new.Change subjectLine to digestTitle - nothing new.skipped is greater than 0If skipped is greater than 0Yes
digestBody to Nothing could be read windowLabel, so there is nothing to summarise.Change digestBody to Nothing could be read windowLabel, so there is nothing to summarise.No
digestBody to Nothing arrived windowLabel. Your inbox is clear and there is nothing waiting on you.Change digestBody to Nothing arrived windowLabel. Your inbox is clear and there is nothing waiting on you.No
subjectLine to digestTitle - mailCount to read.Change subjectLine to digestTitle - mailCount to read.summaryErrorIf a step below fails, save the error as summaryErrorTry
mailList'. Save it as answer.answer.response_text and save it as digestBody.Trim answer.response_text and save it as digestBody.On error
summaryError as text.Show in the output: The summary step did not run: summaryError as text.digestBody is emptyIf digestBody is emptyYes
digestBody to A summary could not be produced this time, so here is everything that arrived.Change digestBody to A summary could not be produced this time, so here is everything that arrived.
mailList.No
No steps
skippedNote to blank.Set skippedNote to blank.skipped is greater than 0If skipped is greater than 0Yes
skippedNote to Change skippedNote to
Left out skipped message(s) that arrived without a readable sender, subject or preview.No
No steps
fullBody to digestTitleSet fullBody to digestTitle
Covering windowLabel.
Messages in this digest: mailCount
digestBody@skippedNote.digestTo.Send an email to digestTo.
Subject: subjectLinefullBody