Searches the web for your question, reads the top results, and writes a Google Doc brief citing every source it used.
Uses
Google Docs
OpenAITavily
Research a question into a sourced brief
Type in a question and run it. The web is searched for it, the top results are read one at a time, and the AI writes a short brief from that text alone, with every claim followed by the number of its source. The brief is saved as a new Google Doc.
The document holds your question, what the sources say with numbered markers in the prose, a numbered list of every source with its link, and a closing line saying how many of the results found were actually used. Nothing enters the brief without a page behind it: the search engine's own answer is never requested, and the AI is told to say plainly when the sources do not answer the question rather than filling the gap from memory. If the search finds nothing, or none of the pages can be read, the run stops and says so instead of producing a confident write-up. A page that will not load is skipped and reported, the number of pages read per run is capped, and a new document is created each run, so nothing you already have is overwritten.
researchQuestion to blank.Set researchQuestion to blank.maxSearchResults to 8.Set maxSearchResults to 8.maxSourcesToRead to 4.Set maxSourcesToRead to 4.charactersPerSource to 6000.Set charactersPerSource to 6000.researchQuestion. Save it as searchResponse.Search the web for researchQuestion. Save it as searchResponse.
Number of results: maxSearchResultssearchResults to searchResponse.results.Set searchResults to searchResponse.results.searchResults and save it as resultsFound.Count the items in searchResults and save it as resultsFound.resultsFound is 0If resultsFound is 0sourceExtracts to an empty list.Set sourceExtracts to an empty list.sourceList to an empty list.Set sourceList to an empty list.sourcesRead to 0.Set sourcesRead to 0.resultsSkipped to 0.Set resultsSkipped to 0.result in searchResults:For each result in searchResults:sourcesRead is greater than or equal to maxSourcesToReadIf sourcesRead is greater than or equal to maxSourcesToReadpageUrl to blank.Set pageUrl to blank.pageTitle to blank.Set pageTitle to blank.resultFieldErrorIf a step below fails, save the error as resultFieldErrorresult.url and save it as pageUrl.Trim result.url and save it as pageUrl.result.title and save it as pageTitle.Trim result.title and save it as pageTitle.A search result arrived without a link or a title. Checking what of it can still be used..Show in the output: A search result arrived without a link or a title. Checking what of it can still be used..pageUrl is empty or pageUrl doesn't contain httpIf pageUrl is empty or pageUrl doesn't contain httpresultsSkipped.Add 1 to resultsSkipped.Skipping a search result with no usable web link - it is not being used as a source..Show in the output: Skipping a search result with no usable web link - it is not being used as a source..pageText to blank.Set pageText to blank.pageReadErrorIf a step below fails, save the error as pageReadErrorpageUrl. Save it as readResponse.Read the contents of pageUrl. Save it as readResponse.readResponse.results.raw_content and save it as pageText.Trim the first item of readResponse.results.raw_content and save it as pageText.pageUrl - it is not being used as a source.Show in the output: Could not read pageUrl - it is not being used as a source.pageText is emptyIf pageText is emptyresultsSkipped.Add 1 to resultsSkipped.pageUrl - it is not being used as a source.Show in the output: No readable text at pageUrl - it is not being used as a source.pageTitle is emptyIf pageTitle is emptypageTitle to pageUrl.Change pageTitle to pageUrl.sourcesRead.Add 1 to sourcesRead.sourceLabel to [sourcesRead].Set sourceLabel to [sourcesRead].sourceLabel pageTitleAdd sourceLabel pageTitle
Link: pageUrl
Page text:
pageText truncated to charactersPerSource characters to the end of sourceExtracts and save it as sourceExtracts.sourceLabel pageTitle - pageUrl to the end of sourceList and save it as sourceList.Add sourceLabel pageTitle - pageUrl to the end of sourceList and save it as sourceList.sourcesRead is 0If sourcesRead is 0resultsFound search results could be read, so there is nothing to write up and no document has been created. The sources are the point here - a brief written without them would only be the model's own recollection.Stop and report a problem: None of the resultsFound search results could be read, so there is nothing to write up and no document has been created. The sources are the point here - a brief written without them would only be the model's own recollection.sourceExtracts with "Join sourceExtracts with
-----
and save it as sourcesText.coverageNote to Sources used: sourcesRead of the resultsFound search results found (resultsSkipped could not be read).Set coverageNote to Sources used: sourcesRead of the resultsFound search results found (resultsSkipped could not be read).promptRules to:Set promptRules to:You are writing a short research brief from a numbered set of sources that were fetched for you. Follow these rules exactly.
1. Use ONLY the source text below. Do not add anything from your own knowledge, even where you are confident it is correct.
2. End every sentence that makes a claim with the number of the source it came from, like [1], or [2][3] where several sources support it.
3. If the sources do not answer the question, say so plainly in your first sentence and then write only what they do cover. Do not fill the gap.
4. Where two sources disagree, say that they disagree and cite bo...prompt to promptRulesSet prompt to promptRules
Question:
researchQuestion
Sources:
sourcesText.prompt. Save it as modelResponse.Ask OpenAI: prompt. Save it as modelResponse.modelResponse.response_text and save it as writeUp.Trim modelResponse.response_text and save it as writeUp.writeUp is emptyIf writeUp is emptydocumentTitle to Research brief: researchQuestion truncated to 120 characters.Set documentTitle to Research brief: researchQuestion truncated to 120 characters.documentBody to QuestionSet documentBody to Question
researchQuestion
What the sources say
writeUp
Sources
sourceList joined by a new line
coverageNote.documentTitle. Save it as newDocument.Create the document documentTitle. Save it as newDocument.newDocument.document_id and save it as documentId.Trim newDocument.document_id and save it as documentId.documentId is emptyIf documentId is emptydocumentId.Add text to documentId.documentBody