Name a subject and it decides which questions are worth asking, then answers each one from a page it actually read.
Uses
Claude
Google Sheets
Jina AI
Serper
Work out the questions worth asking, then answer them
Give it a subject rather than a question, and every week the AI works out the handful of questions whose answers would actually change what you do about it. Each question is searched on the web, the first secure page found is read, and the AI answers from the text of that one page and nothing else.
You end up with a 'Questions and answers' tab that fills up a few questions at a time, one row per question: the date asked, the subject, the question, the answer, the page it came from and what happened. A question the page does not answer is left with an empty answer cell and a note saying so, never filled in from what the AI happens to know, and a question no page could be found for is recorded the same way. Questions already on the tab are skipped, so nothing is asked twice.
Before the first run you need a spreadsheet with a tab named 'Questions and answers' and a heading row in that column order; a missing tab is treated as empty and reported.
sheetUrl to blank.Set sheetUrl to blank.subject to blank.Set subject to blank.answersTab to Questions and answers.Set answersTab to Questions and answers.maxQuestions to 6.Set maxQuestions to 6.askedOn.Get today's date and save it as askedOn.alreadyAsked.Start an empty list and save it as alreadyAsked.answersTabErrorIf a step below fails, save the error as answersTabErrorsheetUrl. Save it as done.Read the rows of sheetUrl. Save it as done.doneRow in done.rows:For each doneRow in done.rows:doneRow.Question and save it as doneQuestion. Trim doneRow.Question and save it as doneQuestion.doneQuestion isn't empty If doneQuestion isn't emptydoneQuestion to the end of alreadyAsked and save it as alreadyAsked.Add doneQuestion to the end of alreadyAsked and save it as alreadyAsked.Could not read the 'Questions and answers' tab, so this run treated it as empty. If that tab does not exist yet, create it..Show in the output: Could not read the 'Questions and answers' tab, so this run treated it as empty. If that tab does not exist yet, create it..planPrompt to You are choosing the questions worth answering about a subject, before anyone researches it.Set planPrompt to You are choosing the questions worth answering about a subject, before anyone researches it.
Write each question on its own line, ending in a question mark. No numbering, no bullets, no preamble, no commentary - only the questions themselves.
Ask the questions whose answers would actually change what someone does about this subject. Prefer questions a public source could settle with facts, figures or dates over questions only an opinion could answer.
Subject: subject
Write at most maxQuestions questions.planPrompt. Save it as plan.Ask Claude: planPrompt. Save it as plan.
Maximum response length: 500plan.response_text and save it as planText.Trim plan.response_text and save it as planText.planText is emptyIf planText is emptyplanText by a new line and save it as questions.Split planText by a new line and save it as questions.answered to 0.Set answered to 0.line in questions:For each line in questions:answered multiplied by 1 is greater than or equal to maxQuestions multiplied…If answered multiplied by 1 is greater than or equal to maxQuestions multiplied…line and save it as question.Trim line and save it as question.question doesn't end with ?If question doesn't end with ?question is less than 12If the length of question is less than 12alreadyAsked contains questionIf alreadyAsked contains questionquestion to the end of alreadyAsked and save it as alreadyAsked.Add question to the end of alreadyAsked and save it as alreadyAsked.answered.Add 1 to answered.questionErrorIf a step below fails, save the error as questionErrorquestion'. Save it as found.Search Google for '@subject question'. Save it as found.pageUrl to blank.Set pageUrl to blank.result in found.results:For each result in found.results:pageUrl is empty If pageUrl is emptyresult.link and save it as link.Trim result.link and save it as link.link in lowercase starts with https://If link in lowercase starts with https://pageUrl to link.Change pageUrl to link.pageUrl is emptyIf pageUrl is emptyanswersTab in sheetUrl.Add a row to answersTab in sheetUrl.pageUrl with Jina. Save it as page.Read the page at pageUrl with Jina. Save it as page.page.content and save it as pageText.Trim page.content and save it as pageText.pageText is less than 200If the length of pageText is less than 200answersTab in sheetUrl.Add a row to answersTab in sheetUrl.pageSection to PAGE TEXT - this is the only material you may use:Set pageSection to PAGE TEXT - this is the only material you may use:
pageText truncated to 12000 characters.askSection to Question: question.Set askSection to Question: question.prompt to You are answering one question using a single web page and nothing else.Set prompt to You are answering one question using a single web page and nothing else.
Rules you must follow:
- Answer only from the page text below. Do not use anything you already know about the subject, and do not fill a gap from memory.
- If the page does not answer the question, reply with exactly NOT ANSWERED FROM THIS PAGE and nothing else. That is a correct answer; a plausible one from memory is not.
- Otherwise answer in a few plain sentences, keeping any figures, names and dates exactly as the page gives them.
askSection
pageSection.prompt. Save it as reply.Ask Claude: prompt. Save it as reply.
Maximum response length: 600reply.response_text and save it as answer.Trim reply.response_text and save it as answer.answer is empty or answer contains NOT ANSWERED FROM THIS PAGE (ignoring…If answer is empty or answer contains NOT ANSWERED FROM THIS PAGE (ignoring…answersTab in sheetUrl.Add a row to answersTab in sheetUrl.answersTab in sheetUrl.Add a row to answersTab in sheetUrl.question this time; it will be tried again on the next run.Show in the output: Nothing was recorded for the question question this time; it will be tried again on the next run.