You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
import{Client,iteratePaginatedAPI,isFullBlock}from'@notionhq/client';// Import Client and types from Notion
3
3
importOpenAIfrom'openai';
4
-
import{askModel}from'../shared/shared.js';
5
4
6
5
constactionDefinition: ActionDefinition={
7
-
key: 'askMyPrivateNotionPage',
8
-
name: 'Ask my Knowledge from Private Notion Page',
6
+
key: 'askPrivateNotionPage',
7
+
name: 'Ask Private Notion Page',
9
8
description:
10
9
'This action enables users to ask questions and receive answers from a knowledge base hosted on a private Notion page. The action accesses the Notion page via its URL using the Notion API and an API key. Users’ questions are processed by OpenAI, which generates answers based on the content retrieved from the page. The action supports all content elements, including toggles.',
// Check if the content length is less than 5 characters
96
+
if(pageContent.length<5){
97
+
thrownewError(`The extracted content is too short: ${pageContent.length} characters. It must be at least 5 characters long.`);
98
+
}
94
99
95
100
// Initialize OpenAI with the provided API key
96
101
constopenai=newOpenAI({apiKey: openaiApiKey});
97
102
98
-
// Create the prompt with instructions for the model
99
-
constprompt=`
100
-
You are an FAQ expert. When asked a question or given a request related to a specific topic, you provide an accurate and concise answer based strictly on the content provided.
101
-
You respond in the same language as the user’s input and adjust your answer to fit the context of the request, whether it’s a direct question or an indirect inquiry.
102
-
You never guess or paraphrase — only answer if the explicit content for that request is available.
103
-
If there are any disclaimers or indications in the content that it should not be shared with clients or is a work in progress, include that information only if it is explicitly mentioned.
104
-
Here is the content you should use to generate your answer:
105
-
106
-
”${pageContent}”
107
-
108
-
Based on this content, please respond to the following request or question with high confidence:
109
-
110
-
”${question}”.
111
-
If you are not confident that the content fully addresses the request, respond with:
112
-
‘My content source does not provide enough context to answer your request. If you want to report this knowledge gap to the admin, just trigger another action with “Report knowledge gap:” and add your original request.’
103
+
// Create the system message with instructions for the model
104
+
constsystemMessage=`You are an FAQ expert. When asked a question or given a request related to a specific topic, you provide an accurate and concise answer based strictly on the content provided.
105
+
You respond in the same language as the user’s input and adjust your answer to fit the context of the request, whether it’s a direct question or an indirect inquiry.
106
+
You never guess or paraphrase — only answer if the explicit content for that request is available.
107
+
If there are any disclaimers or indications in the content that it should not be shared with clients or is a work in progress, include that information only if it is explicitly mentioned.
108
+
Here is the content you should use to generate your answer:
109
+
”${pageContent}”
113
110
`;
114
-
111
+
112
+
// Set the user's question separately
113
+
constuserQuestion=`Based on this content, please respond to the following request or question with high confidence:
114
+
”${question}”.
115
+
If you are not confident that the content fully addresses the request, respond with:
116
+
‘My content source does not provide enough context to answer your request. If you want to report this knowledge gap to the admin, just trigger another action with “Report knowledge gap:” and add your original request.’
117
+
`;
118
+
115
119
// Request completion from OpenAI using the specified model
'This plugin enables interaction with Notion-based knowledge repositories, allowing users to query and retrieve answers from both public and private Notion pages. The plugin integrates with OpenAI to provide high-certainty answers based on the content available in Notion and suggests follow-ups in case of missing content.',
0 commit comments