本页面为开发者提供构建特定应用GPT Action的说明与指南。在继续之前,请确保您已熟悉以下信息:
此特定GPT操作概述了如何连接到Notion。该操作会接收用户的问题,利用Notion的搜索功能扫描相关页面,然后返回匹配页面的信息。
价值与示例商业应用场景
价值: 用户现在可以利用ChatGPT的自然语言处理能力,直接在Notion中连接、查询和整合他们的知识。管理员可以通过该集成显式共享页面来管理访问权限。
示例用例:
- 一名新员工希望快速获取有关设置新系统的操作指南信息
- 支持代理需要快速从Notion检索信息而无需阅读整个文档
- 用户希望综合信息并创建摘要或转换,以便用于工作的其他方面
应用信息
应用密钥链接
在开始之前,请查看应用程序中的这些链接:
- 应用网站: https://www.notion.so/
- 应用API文档:https://developers.notion.com/reference/intro
- Notion Authorization Approach: https://developers.notion.com/docs/authorization
- 注意:Notion仅允许使用"公共集成"进行OAuth验证。请参考链接文档以确定最适合您需求的方案
应用前提条件
在开始之前,请确保您已在应用程序环境中完成以下步骤:
- 设置一个包含预填充页面的Notion工作区
- 通过Notion分享页面在特定Wiki中效果最佳。建议将您的知识库组织成一个或多个Wiki
ChatGPT 步骤
自定义GPT指令
创建自定义GPT后,请将以下文本复制到指令面板中。有问题吗?查看入门示例详细了解此步骤的操作方法。
**Context**: You are a helpful chatbot focussed on retrieving information from a company's Notion. An administrator has given you access to a number of useful Notion pages. You are to act similar to a librarian and be helpful answering and finding answers for users' questions.
**Instructions**:
1. Use the search functionality to find the most relevant page or pages.
- Display the top 3 pages. Include a formatted list containing: Title, Last Edit Date, Author.
- The Title should be a link to that page.
1.a. If there are no relevant pages, reword the search and try again (up to 3x)
1.b. If there are no relevant pages after retries, return "I'm sorry, I cannot find the right info to help you with that question"
2. Open the most relevant article, retrieve and read all of the contents (including any relevant linked pages or databases), and provide a 3 sentence summary. Always provide a quick summary before moving to the next step.
3. Ask the user if they'd like to see more detail. If yes, provide it and offer to explore more relevant pages.
**Additional Notes**:
- If the user says "Let's get started", introduce yourself as a librarian for the Notion workspace, explain that the user can provide a topic or question, and that you will help to look for relevant pages.
- If there is a database on the page. Always read the database when looking at page contents.
OpenAPI 规范
创建自定义GPT后,在操作面板中复制以下文本。有问题吗?查看入门示例了解此步骤的详细操作方式。
openapi: 3.1.0
info:
title: Notion API
description: API for interacting with Notion's pages, databases, and users.
version: 1.0.0
servers:
- url: https://api.notion.com/v1
description: Main Notion API server
paths:
/users:
get:
operationId: listAllUsers
summary: List all users
parameters:
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
results:
type: array
items:
type: object
properties:
id:
type: string
name:
type: string
avatar_url:
type: string
type:
type: string
/blocks/{block_id}/children:
get:
operationId: retrieveBlockChildren
summary: Retrieve block children
parameters:
- name: block_id
in: path
required: true
schema:
type: string
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
object:
type: string
results:
type: array
items:
type: object
properties:
id:
type: string
type:
type: string
has_children:
type: boolean
/comments:
get:
operationId: retrieveComments
summary: Retrieve comments
parameters:
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
results:
type: array
items:
type: object
properties:
id:
type: string
text:
type: string
created_time:
type: string
format: date-time
created_by:
type: object
properties:
id:
type: string
name:
type: string
/pages/{page_id}/properties/{property_id}:
get:
operationId: retrievePagePropertyItem
summary: Retrieve a page property item
parameters:
- name: page_id
in: path
required: true
schema:
type: string
- name: property_id
in: path
required: true
schema:
type: string
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
id:
type: string
type:
type: string
title:
type: array
items:
type: object
properties:
type:
type: string
text:
type: object
properties:
content:
type: string
/databases/{database_id}/query:
post:
operationId: queryDatabase
summary: Query a database
parameters:
- name: database_id
in: path
required: true
schema:
type: string
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
filter:
type: object
sorts:
type: array
items:
type: object
start_cursor:
type: string
page_size:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
object:
type: string
results:
type: array
items:
type: object
next_cursor:
type: string
has_more:
type: boolean
/search:
post:
operationId: search
summary: Search
parameters:
- name: Notion-Version
in: header
required: true
schema:
type: string
example: 2022-06-28
constant: 2022-06-28
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
filter:
type: object
properties:
value:
type: string
property:
type: string
sort:
type: object
properties:
direction:
type: string
timestamp:
type: string
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
object:
type: string
results:
type: array
items:
type: object
properties:
id:
type: string
title:
type: array
items:
type: object
properties:
type:
type: string
text:
type: object
properties:
content:
type: string
认证说明
以下是设置与这个第三方应用程序进行身份验证的说明。
预操作步骤
在ChatGPT中设置身份验证之前,请在Notion中执行以下步骤。
- 前往您工作区的Notion设置页面
- 导航至 我的连接 > 开发或管理集成
- 创建标记为内部的新集成
- 找到您的集成并标记为“内部集成密钥”的API密钥。这是该集成的承载令牌。
注意! 您需要与集成共享特定页面、数据库或wiki,才能在ChatGPT中访问它们。操作方法是点击页面右上角的...按钮,然后选择相应的连接。
注意! Notion允许被标记为"公开"的集成使用OAuth认证。请查阅Notion的认证文档以确定哪种集成方式最适合您的需求。
在ChatGPT中
在ChatGPT中,点击"身份验证"并选择"API密钥"。输入以下信息。
- API Key: 使用上述步骤中的内部集成密钥
- 认证类型: Bearer
常见问题与故障排除
- 搜索无结果 如果在执行搜索时未返回任何页面,请再次确认您已从Notion向该应用程序共享了相关页面
是否有您希望我们优先考虑的集成方案?我们的集成是否存在错误?请在GitHub上提交PR或问题,我们会尽快查看。