When someone asks a question in Slack, finds the Notion FAQ pages that match and drafts an answer from them for you to approve.
Uses
ClaudeNotion
Slack
Answer Slack questions from your Notion FAQ
request.When someone posts in a channel. Save it as request.teamContext to blank.Set teamContext to blank.maxPages to 5.Set maxPages to 5.questionText to blank.Set questionText to blank.readErrorIf a step below fails, save the error as readErrorTry
request.text and save it as questionText.Trim request.text and save it as questionText.On error
The Slack message carried no text to read, so it was skipped..Show in the output: The Slack message carried no text to read, so it was skipped..questionText is emptyIf questionText is emptyYes
No
No steps
questionText and save it as screening.Run an AI agent: The message posted in the channel: questionText and save it as screening.screening.output.is_question is noIf screening.output.is_question is noYes
Else if @screening.output.is_question is not "yes"
@screening.output.is_question), so nothing was searched or posted. The message was: questionText.Stop and report a problem: The AI could not tell whether this message is a question (it answered @screening.output.is_question), so nothing was searched or posted. The message was: questionText.Otherwise
No steps
screening.output.search_words and save it as searchWords.Take the first 3 items of screening.output.search_words and save it as searchWords.searchWords is emptyIf searchWords is emptyYes
searchWords to [questionText].Change searchWords to [questionText].No
No steps
foundPages to an empty list.Set foundPages to an empty list.searchWord in searchWords:For each searchWord in searchWords:searchWord. Save it as found.Search pages for searchWord. Save it as found.foundPages and found.pages into one list and save it as foundPages.Combine foundPages and found.pages into one list and save it as foundPages.id from foundPages and save it as uniquePages.Remove duplicates of id from foundPages and save it as uniquePages.maxPages items of uniquePages and save it as pagesToRead.Take the first maxPages items of uniquePages and save it as pagesToRead.searchWords with , and save it as searchedFor.Join searchWords with , and save it as searchedFor.sourceBlocks to an empty list.Set sourceBlocks to an empty list.sourceLinks to an empty list.Set sourceLinks to an empty list.page in pagesToRead:For each page in pagesToRead:pageTitle to blank.Set pageTitle to blank.titleErrorIf a step below fails, save the error as titleErrorTry
page.title and save it as pageTitle.Trim page.title and save it as pageTitle.On error
Skipped a search result that had no title..Show in the output: Skipped a search result that had no title..pageTitle isn't emptyIf pageTitle isn't emptyYes
pageLink to blank.Set pageLink to blank.linkErrorIf a step below fails, save the error as linkErrorTry
page.url and save it as pageLink.Trim page.url and save it as pageLink.On error
pageTitle.Show in the output: No link came back for the page pageTitle.pageDetails to (only the title and link are available).Set pageDetails to (only the title and link are available).detailErrorIf a step below fails, save the error as detailErrorTry
page.id. Save it as fullPage.Get page.id. Save it as fullPage.fullPage.properties to a bulleted list and save it as readable.Convert fullPage.properties to a bulleted list and save it as readable.readable isn't emptyIf readable isn't emptyYes
pageDetails to readable.Change pageDetails to readable.No
No steps
On error
pageTitle, so only its title and link were used: detailError as text.Show in the output: Could not read the details of the page pageTitle, so only its title and link were used: detailError as text.pageTitleAdd PAGE: pageTitle
LINK: pageLink
DETAILS: pageDetails to the end of sourceBlocks and save it as sourceBlocks.pageTitle pageLink to the end of sourceLinks and save it as sourceLinks.Add - pageTitle pageLink to the end of sourceLinks and save it as sourceLinks.No
No steps
sourceBlocks is emptyIf sourceBlocks is emptyYes
request.channel_id.Reply in a thread in request.channel_id.
Reply To: request.message_tsI could not find a page in our Notion workspace about this (I searched page titles for: searchedFor), so there is nothing written down for me to answer from. Someone will need to answer this one by hand.searchedFor), so no answer was drafted.Finish the run: No Notion page title matched the search (searchedFor), so no answer was drafted.No
No steps
sourceBlocks with a blank line and save it as sources.Join sourceBlocks with a blank line and save it as sources.sourceLinks with a new line and save it as linkList.Join sourceLinks with a new line and save it as linkList.teamContext
The question:
questionText
The pages found in Notion, with their links and property values:
sources'. Save it as drafted.
Maximum response length: 700drafted.response_text and save it as answer.Trim drafted.response_text and save it as answer.answer is empty or answer contains NOT_IN_THE_WIKI (ignoring case)If answer is empty or answer contains NOT_IN_THE_WIKI (ignoring case)Yes
request.channel_id.Reply in a thread in request.channel_id.
Reply To: request.message_tsI found these pages in our Notion workspace, but none of them answers this:
linkList
Someone will need to answer this one by hand.No
No steps
questionText Save it as review.Request approval: Post this answer in Slack to: questionText Save it as review.Someone asked in Slack:
questionText
Drafted answer:
answer
Drafted from these Notion pages:
linkList
...review.approved is yesIf review.approved is yesYes
request.channel_id.Reply in a thread in request.channel_id.
Reply To: request.message_tsanswer
From our Notion workspace:
linkList
_Drafted from the pages above and checked by a person before posting._No
outcomeNote to:Set outcomeNote to:A drafted answer was checked and not approved, so only the links are shared here.review.timed_out is yesIf review.timed_out is yesYes
outcomeNote to:Change outcomeNote to:Nobody checked the drafted answer within three days, so only the links are shared here.No
No steps
request.channel_id.Reply in a thread in request.channel_id.
Reply To: request.message_tsThese pages in our Notion workspace look relevant to your question:
linkList@outcomeNote