Connecting Notion API to a GPT using Actions?

Objective:
To create a GPT called “Sales Support” that can access my company Notion account and search through databases, pages, comments etc. and therefore have a full understanding of my clients, projects, my teams tasks etc.

I want to be able to interface with this GPT through the ChatGPT interface as a bot that will be published privately.

Problem:

I am unable to setup the right schema in the ChatGPT interface.
I am unable to use the ActionsGPT to create it for me as well.

Questions:
Have anyone else solved this before?
Can you share your schema?
Or can you look through my schema and see what is wrong?

I have tried to copy-paste Notions OpenAPI schema from the following github account: APIs-guru. (I am unable to link directly)

This does not work.

I have tried to download the Notions POSTMAN setup and feed both URLS, request JSON etc. to ActionsGPT and have it generate Schema for me.
This does not work.

ActionsGPT schema:

openapi: 3.0.0
info:
  title: Notion Search API Integration
  description: his API specification outlines the endpoints for interacting with Notion to retrieve files, information,
    and perform searches using a custom GPT.
  version: 1.0.1
servers:
  - url: https://api.notion.com/v1
    description: Main Notion API server
paths:
  /v1/search:
    post:
      operationId: searchInNotion
      summary: Search in Notion
      parameters:
        - in: header
          name: Notion-Version
          schema:
            example: 2022-06-28
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  example: searchTerm
                sort:
                  type: object
                  properties:
                    direction:
                      type: string
                      enum:
                        - ascending
                        - descending
                    timestamp:
                      type: string
                      example: last_edited_time
      responses:
        "200":
          description: Search results returned successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: list
                  results:
                    type: array
                    items:
                      $ref: "#/components/schemas/PageResult"
                  next_cursor:
                    type: string
                  has_more:
                    type: boolean
components:
  schemas:
    PageResult:
      type: object
      properties:
        object:
          type: string
          example: page
        id:
          type: string
        created_time:
          type: string
        last_edited_time:
          type: string

This is the debu message:

{
  "domain": "api.notion.com",
  "method": "post",
  "path": "/v1/search",
  "operation": "searchInNotion",
  "operation_hash": "566c1f5d4ba759fe0ea71450ee8edab159d63b3f",
  "is_consequential": true,
  "params": {
    "query": "lifetime deals"
  }
}

Hi steffengroenandersen,

I have also been trying to create a GPT similar to yours that can take actions on my private Notion workspace. Project has been lying on the shelf so happy to find someone else who is attempting the same.

It looks like your schema is valid but I have not tested it yet myself.

I tried using this postman to openapi converter from joolfe at github dot io.
Also did not work. I get errors on some of the API endpoints when trying to feed it into a GPT.

Just found a Postman collection (postman to openapi) that apparently should result in a schema in the response, but not working yet.

Still pretty motivated to get it to work. If I cannot get it done in one go (feeding a schema to a GPT) I am considering building the functions one by one in code instead of through the OpenAI platform, similar to Open AI’s cookbook “how to call functions with chat models”.

1 Like

Please keep me in the loop if you find a solution that works! :slight_smile:

I will also continue to work on it and will report back if I find a solution.

Best regards

I built a custom GPT to help with cases like this. Allows you to iterate towards building out the Action Just started a quick chat to produce the Notion API spec you were looking for. If you have the link to the Postman, happy to try inputting into the custom GPT and see if it can help speed up the process.

https://chat.openai.com/share/c4281d9b-6496-47b8-a592-fe3db08506c9

and here is the start of the output: Swagger UI

2 Likes

95% working - was able to convert the postman to swagger with my GPT

couple methods are still throwing errors that im still looking into.

here is the swagger output : Swagger UI

@steffengroenandersen and @gaspardbos let me know how this works for you: ChatGPT - MyNotion

I just saw that La Vague (a project that does browser automation with OpenAI and Selenium) posted a Notion use case. This wouldn’t only work for Notion workspaces that you have access to but Notion public sites as well. Interesting to have an agent that can edit your workspace; for example for updating pages in Kanban boards.

It’s not really working like I would expect. Sharing a bearer token works to retrieve pages that include the name “projects” upon the question “what are my latest projects”. But then the content of those pages cannot be returned; default error message that access needs to be configured.

what are your scopes? That is the only thing I can think of.