mirror of
https://github.com/openai/openai-cookbook
synced 2024-11-11 13:11:02 +00:00
New notion page branch (#1309)
Co-authored-by: Aaron Wilkowitz <157151487+aaronwilkowitz-openai@users.noreply.github.com> Co-authored-by: Aaron Wilkowitz <aaronwilkowitz@openai.com>
This commit is contained in:
parent
2ad13693fc
commit
f755098529
@ -126,4 +126,9 @@ aa-openai:
|
||||
alwestmo-openai:
|
||||
name: "Anthony Westmoreland"
|
||||
website: "https://www.linkedin.com/in/westmorelandanthony/"
|
||||
avatar: "https://avatars2.githubusercontent.com/u/175844346"
|
||||
avatar: "https://avatars2.githubusercontent.com/u/175844346"
|
||||
|
||||
dan-openai:
|
||||
name: "Daniel Halpern"
|
||||
website: "https://www.linkedin.com/in/dhalp/"
|
||||
avatar: "https://avatars.githubusercontent.com/u/175367970"
|
555
examples/chatgpt/gpt_actions_library/gpt_action_Notion.ipynb
Normal file
555
examples/chatgpt/gpt_actions_library/gpt_action_Notion.ipynb
Normal file
@ -0,0 +1,555 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# GPT Action Library: Notion"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information: \n",
|
||||
"- [Introduction to GPT Actions](https://platform.openai.com/docs/actions)\n",
|
||||
"- [Introduction to GPT Actions Library](https://platform.openai.com/docs/actions/actions-library)\n",
|
||||
"- [Example of Buliding a GPT Action from Scratch](https://platform.openai.com/docs/actions/getting-started)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This particular GPT Action provides an overview of how to connect to **Notion**. This Action takes a user’s question, scans the relevant Notion pages using Notions search functionality, and then returns information on the matching pages."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Value + Example Business Use Cases"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Value**: Users can now harness ChatGPT’s natural language capabilities to directly connect to, query, and synthesize their knowledge within Notion. Administrators can explicitly share pages with the integration to manage access.\n",
|
||||
"\n",
|
||||
"**Example Use Cases**: \n",
|
||||
"- A new employee seeks quick how-to information on setting up a new system\n",
|
||||
"- A support agent needs to quickly retrieve information from Notion without reading the entire document\n",
|
||||
"- Users want to synthesize information and create summaries or transformations for use in other aspects of their work"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Application Information"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Application Key Links"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Check out these links from the application before you get started:\n",
|
||||
"- Application Website: https://www.notion.so/\n",
|
||||
"- Application API Documentation: https://developers.notion.com/reference/intro\n",
|
||||
"- Notion Authorization Approach: https://developers.notion.com/docs/authorization\n",
|
||||
" - NOTE: Notion only allows OAuth with \"Public Integrations.\" Refer to the linked documentation to determine what is best suited for your needs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Application Prerequisites"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Before you get started, make sure you go through the following steps in your application environment:\n",
|
||||
"- Set up a notion workspace with populated pages\n",
|
||||
"- Sharing pages through notion works best with specific Wikis. Consider organizing your knowledge base into a wiki or set of wikis"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## ChatGPT Steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Custom GPT Instructions "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://cookbook.openai.com/examples/chatgpt/gpt_actions_library/.gpt_action_getting_started) to see how this step works in more detail."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"vscode": {
|
||||
"languageId": "plaintext"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"**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.\n",
|
||||
"\n",
|
||||
"**Instructions**:\n",
|
||||
"1. Use the search functionality to find the most relevant page or pages.\n",
|
||||
"- Display the top 3 pages. Include a formatted list containing: Title, Last Edit Date, Author.\n",
|
||||
"- The Title should be a link to that page.\n",
|
||||
"1.a. If there are no relevant pages, reword the search and try again (up to 3x)\n",
|
||||
"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\"\n",
|
||||
"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.\n",
|
||||
"3. Ask the user if they'd like to see more detail. If yes, provide it and offer to explore more relevant pages.\n",
|
||||
"\n",
|
||||
"**Additional Notes**: \n",
|
||||
"- 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.\n",
|
||||
"- If there is a database on the page. Always read the database when looking at page contents."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### OpenAPI Schema "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"vscode": {
|
||||
"languageId": "yaml"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"openapi: 3.1.0\n",
|
||||
"info:\n",
|
||||
" title: Notion API\n",
|
||||
" description: API for interacting with Notion's pages, databases, and users.\n",
|
||||
" version: 1.0.0\n",
|
||||
"servers:\n",
|
||||
" - url: https://api.notion.com/v1\n",
|
||||
" description: Main Notion API server\n",
|
||||
"paths:\n",
|
||||
" /users:\n",
|
||||
" get:\n",
|
||||
" operationId: listAllUsers\n",
|
||||
" summary: List all users\n",
|
||||
" parameters:\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" name:\n",
|
||||
" type: string\n",
|
||||
" avatar_url:\n",
|
||||
" type: string\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" /blocks/{block_id}/children:\n",
|
||||
" get:\n",
|
||||
" operationId: retrieveBlockChildren\n",
|
||||
" summary: Retrieve block children\n",
|
||||
" parameters:\n",
|
||||
" - name: block_id\n",
|
||||
" in: path\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" object:\n",
|
||||
" type: string\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" has_children:\n",
|
||||
" type: boolean\n",
|
||||
" /comments:\n",
|
||||
" get:\n",
|
||||
" operationId: retrieveComments\n",
|
||||
" summary: Retrieve comments\n",
|
||||
" parameters:\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" text:\n",
|
||||
" type: string\n",
|
||||
" created_time:\n",
|
||||
" type: string\n",
|
||||
" format: date-time\n",
|
||||
" created_by:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" name:\n",
|
||||
" type: string\n",
|
||||
" /pages/{page_id}/properties/{property_id}:\n",
|
||||
" get:\n",
|
||||
" operationId: retrievePagePropertyItem\n",
|
||||
" summary: Retrieve a page property item\n",
|
||||
" parameters:\n",
|
||||
" - name: page_id\n",
|
||||
" in: path\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - name: property_id\n",
|
||||
" in: path\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" title:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" text:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" content:\n",
|
||||
" type: string\n",
|
||||
" /databases/{database_id}/query:\n",
|
||||
" post:\n",
|
||||
" operationId: queryDatabase\n",
|
||||
" summary: Query a database\n",
|
||||
" parameters:\n",
|
||||
" - name: database_id\n",
|
||||
" in: path\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" requestBody:\n",
|
||||
" required: true\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" filter:\n",
|
||||
" type: object\n",
|
||||
" sorts:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" start_cursor:\n",
|
||||
" type: string\n",
|
||||
" page_size:\n",
|
||||
" type: integer\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" object:\n",
|
||||
" type: string\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" next_cursor:\n",
|
||||
" type: string\n",
|
||||
" has_more:\n",
|
||||
" type: boolean\n",
|
||||
" /search:\n",
|
||||
" post:\n",
|
||||
" operationId: search\n",
|
||||
" summary: Search\n",
|
||||
" parameters:\n",
|
||||
" - name: Notion-Version\n",
|
||||
" in: header\n",
|
||||
" required: true\n",
|
||||
" schema:\n",
|
||||
" type: string\n",
|
||||
" example: 2022-06-28\n",
|
||||
" constant: 2022-06-28\n",
|
||||
" requestBody:\n",
|
||||
" required: true\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" query:\n",
|
||||
" type: string\n",
|
||||
" filter:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" value:\n",
|
||||
" type: string\n",
|
||||
" property:\n",
|
||||
" type: string\n",
|
||||
" sort:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" direction:\n",
|
||||
" type: string\n",
|
||||
" timestamp:\n",
|
||||
" type: string\n",
|
||||
" responses:\n",
|
||||
" '200':\n",
|
||||
" description: Successful response\n",
|
||||
" content:\n",
|
||||
" application/json:\n",
|
||||
" schema:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" object:\n",
|
||||
" type: string\n",
|
||||
" results:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" id:\n",
|
||||
" type: string\n",
|
||||
" title:\n",
|
||||
" type: array\n",
|
||||
" items:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" type:\n",
|
||||
" type: string\n",
|
||||
" text:\n",
|
||||
" type: object\n",
|
||||
" properties:\n",
|
||||
" content:\n",
|
||||
" type: string"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Authentication Instructions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Below are instructions on setting up authentication with this 3rd party application."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Pre-Action Steps"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Before you set up authentication in ChatGPT, please take the following steps in the Notion."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"1. Go to the Notion Settings Page for your workspace\n",
|
||||
"2. Navigate to My Connections > Develop or Manage Integrations\n",
|
||||
"3. Create new Integration marked as Internal\n",
|
||||
"4. Locate your integration and find the API Key labeled: Internal Integration Secret. This is the bearer token for this integration.\n",
|
||||
"\n",
|
||||
"**NOTE!** You need to share specific pages, databases, or wikis with the integration in order to access them in ChatGPT. Do this by selecting the ... button on the upper right of a page and select the appropriate connection.\n",
|
||||
"\n",
|
||||
"**NOTE!** Notion allows integrations to leverage OAuth if they are marked as \"Public.\" Review [Notion's Auth Documentation](https://developers.notion.com/docs/authorization) to determine what integration path is best for your needs."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"![notion_connections.png](../../../images/creating_notion_integration.png)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"![sharing_notion_pages.png](../../../images/sharing_notion_with_GPT.png)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### In ChatGPT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In ChatGPT, click on \"Authentication\" and choose **\"API Key\"**. Enter in the information below. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- **API Key**: Use Internal Integration Secret from steps above\n",
|
||||
"- **Auth Type**: Bearer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### FAQ & Troubleshooting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- *Search returns nothing* If you don't see any pages returned when running a search, double check that you've shared relevant pages with the application from Notion"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"*Are there integrations that you’d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we’ll take a look.*\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
BIN
images/creating_notion_integration.png
Normal file
BIN
images/creating_notion_integration.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 847 KiB |
BIN
images/sharing_notion_with_GPT.png
Normal file
BIN
images/sharing_notion_with_GPT.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 991 KiB |
@ -1436,3 +1436,12 @@
|
||||
tags:
|
||||
- gpt-actions-library
|
||||
- chatgpt
|
||||
|
||||
- title: GPT Actions library - Notion
|
||||
path: examples/chatgpt/gpt_actions_library/gpt_action_notion.ipynb
|
||||
date: 2024-07-25
|
||||
authors:
|
||||
- dan-openai
|
||||
tags:
|
||||
- gpt-actions-library
|
||||
- chatgpt
|
||||
|
Loading…
Reference in New Issue
Block a user