Every morning, turns the news logged in your sheet into LinkedIn post ideas for your area of interest, emails them, and clears the sheet.
Uses
Claude
Gmail
Google Sheets
Get LinkedIn post ideas from the news in your sheet
newsSheetUrl to blank.Set newsSheetUrl to blank.newsTab to News.Set newsTab to News.recipientEmail to blank.Set recipientEmail to blank.areaOfInterest to blank.Set areaOfInterest to blank.ideasPerEmail to 5.Set ideasPerEmail to 5.maxStoriesToRank to 250.Set maxStoriesToRank to 250.areaOfInterest and save it as interest.Trim areaOfInterest and save it as interest.today.Get today's date and save it as today.dateLabel to the weekday name of today today.Set dateLabel to the weekday name of today today.sheet to nothing.Set sheet to nothing.readErrorIf a step below fails, save the error as readErrorTry
newsSheetUrl. Save it as sheet.Read the rows of newsSheetUrl. Save it as sheet.On error
readError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.Stop and report a problem: The news sheet could not be read (readError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.sheet.rows and save it as totalLogged.Count the items in sheet.rows and save it as totalLogged.sheet.rows where the first match in item as text isn't empty and save it as stories.Keep each item in sheet.rows where the first match in item as text isn't empty and save it as stories.stories and save it as usable.Count the items in stories and save it as usable.usable is 0If usable is 0Yes
recipientEmail.Send an email to recipientEmail.
Subject: LinkedIn content ideas - nothing logged - dateLabelNo stories were logged in the '@newsTab' tab since the last email, so there are no content ideas today. It is worth checking that whatever fills that sheet is still running.No
No steps
capped to false.Set capped to false.usable is greater than maxStoriesToRankIf usable is greater than maxStoriesToRankYes
stories from position usable minus maxStoriesToRank on and save it as stories.Take stories from position usable minus maxStoriesToRank on and save it as stories.capped to true.Change capped to true.No
No steps
catalogue to an empty list.Set catalogue to an empty list.position to 0.Set position to 0.story in stories:For each story in stories:position.Add 1 to position.positionAdd Story position
story as a bulleted list truncated to 600 characters using ... as the ellipsis to the end of catalogue and save it as catalogue.catalogue with a blank line and save it as catalogueText.Join catalogue with a blank line and save it as catalogueText.ranked to nothing.Set ranked to nothing.rankingErrorIf a step below fails, save the error as rankingErrorTry
interest.Ask Claude: 'You help someone who posts on LinkedIn about: interest.
Below are the length of stories news stories logged since their last email, each labelled 'Story' and a number, with the fields that were recorded for it. Choose the ideasPerEmail that would make the best LinkedIn posts for them: stories their audience would care about, that give them something to say in their own area, and that are new rather than repeated.
Reply with the numbers of the stories you choose and nothing else: best first, one number per line. No titles, no reasons, no headings. Never give a number that is not in the list. If fewer stories than asked for genuinely suit their area, give fewer. When several rows report the same event, choose one of them.
The stories:
catalogueText'. Save it as ranked.
Maximum response length: 400On error
rankingError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.Stop and report a problem: Claude could not rank today's stories (rankingError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.ranked.response_text and save it as rankingText.Trim ranked.response_text and save it as rankingText.rankingText and save it as picks.Extract all matches from rankingText and save it as picks.chosen to an empty list.Set chosen to an empty list.chosenPositions to an empty list.Set chosenPositions to an empty list.pick in picks:For each pick in picks:number to +pick.Set number to +pick.chosen is less than ideasPerEmail and number is greater than or…If the length of chosen is less than ideasPerEmail and number is greater than or…Yes
stories[number minus 1] to the end of chosen and save it as chosen.Add stories[number minus 1] to the end of chosen and save it as chosen.number to the end of chosenPositions and save it as chosenPositions.Add number to the end of chosenPositions and save it as chosenPositions.No
No steps
chosen is emptyIf chosen is emptyYes
rankingText truncated to 300 characters using ... as the ellipsis Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.Stop and report a problem: Claude's ranking could not be read as a list of story numbers. It replied: rankingText truncated to 300 characters using ... as the ellipsis Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.No
No steps
shortlist to an empty list.Set shortlist to an empty list.rank to 0.Set rank to 0.story in chosen:For each story in chosen:rank.Add 1 to rank.rankAdd Story rank
story as a bulleted list truncated to 1500 characters using ... as the ellipsis to the end of shortlist and save it as shortlist.shortlist with a blank line and save it as shortlistText.Join shortlist with a blank line and save it as shortlistText.emailBody to blank.Set emailBody to blank.writingErrorIf a step below fails, save the error as writingErrorTry
dateLabel. You are writing for someone who posts on LinkedIn about: interest.Ask Claude: 'Today is dateLabel. You are writing for someone who posts on LinkedIn about: interest.
Below are the the length of chosen news stories chosen as today's raw material, best first, each with the fields that were logged for it (usually a title, a link and a summary, sometimes a source and a date).
Write the email that turns each story into one LinkedIn post idea. Rules you must follow:
- Plain text only. No Markdown, no HTML, no asterisks, hashes or underscores: this is sent as a plain-text email.
- Open with a one-line greeting for the day, then one or two sentences on the thread running through today's stories.
- Then the ideas, numbered, in the order given. For each one give, on separate lines: Hook - the opening line the post could start with, written in their voice and specific to their area; Angle - one or two sentences on the take they could bring to it and why their audience would care; Talking points - two or three short lines drawn only from the story's fields; Format - one suggestion such as a short opinion, a numbered list, a personal story or a question to the audience; Source - the link on its own line exactly as it appears in the fields below.
- Use only what the fields below say. Do not invent facts, figures, quotes or links, and do not add stories. If a story's fields say little, keep its idea short.
- Close with one short line. Output only the body of the email: no subject line.
The stories, best first:
shortlistText'. Save it as written.
Maximum response length: 3000written.response_text and save it as emailBody.Trim written.response_text and save it as emailBody.On error
writingError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.Stop and report a problem: Claude could not write today's content ideas (writingError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.emailBody is emptyIf emailBody is emptyYes
No
No steps
footer to Set footer to
---
Chosen from usable stories logged in the '@newsTab' tab since the last email, for someone posting about: interest.capped is yesIf capped is yesYes
footer to footer Only the newest maxStoriesToRank were ranked.Change footer to footer Only the newest maxStoriesToRank were ranked.No
No steps
sendErrorIf a step below fails, save the error as sendErrorTry
recipientEmail.Send an email to recipientEmail.
Subject: LinkedIn content ideas - dateLabelemailBody plus footerOn error
sendError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.Stop and report a problem: The content ideas could not be sent (sendError.message). Nothing was sent and the sheet was left as it is, so tomorrow's email will have today's stories to choose from as well.headerRow to an empty list.Set headerRow to an empty list.headerErrorIf a step below fails, save the error as headerErrorTry
newsTab in newsSheetUrl. Save it as headerCells.Read row 1 of newsTab in newsSheetUrl. Save it as headerCells.headerRow to headerCells.values.Change headerRow to headerCells.values.On error
headerError.message), so the sheet was not cleared. Clear it by hand before tomorrow's stories arrive, or tomorrow's email will repeat today's.Stop and report a problem: The content ideas were sent, but the header row of the news sheet could not be read (headerError.message), so the sheet was not cleared. Clear it by hand before tomorrow's stories arrive, or tomorrow's email will repeat today's.headerRow is emptyIf headerRow is emptyYes
No
No steps
clearErrorIf a step below fails, save the error as clearErrorTry
newsTab in newsSheetUrl.Clear the tab newsTab in newsSheetUrl.On error
clearError.message). Clear it by hand before tomorrow's stories arrive, or tomorrow's email will repeat today's.Stop and report a problem: The content ideas were sent, but the news sheet could not be cleared (clearError.message). Clear it by hand before tomorrow's stories arrive, or tomorrow's email will repeat today's.restoreErrorIf a step below fails, save the error as restoreErrorTry
newsTab in newsSheetUrl.Overwrite row 1 of newsTab in newsSheetUrl.On error
restoreError.message). Put this header row back before tomorrow's stories arrive: headerRow joined by , .Stop and report a problem: The content ideas were sent, but although the news sheet was cleared, its header row could not be written back (restoreError.message). Put this header row back before tomorrow's stories arrive: headerRow joined by , .chosen LinkedIn content ideas chosen from usable stories and cleared the '@newsTab' tab for tomorrow.Show in the output: Sent the length of chosen LinkedIn content ideas chosen from usable stories and cleared the '@newsTab' tab for tomorrow.