# Notion

{% hint style="info" %}
The following documentation is for **Notion v1.2.3** *(BDK)*.
{% endhint %}

## Overview

Notion is an all-in-one workspace that combines notes, databases, wikis, and project management capabilities. This integration allows automated page creation, database updates, content management, and knowledge base maintenance. Organize information effectively and automate documentation workflows.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **Notion**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

## Procedures

### to create a (new page) in *notion*

Create a new page in Notion, following the BDK NotionPage model as an input.

**Input Concepts**

| Concept                    | Description                 | Type          | Required | Default Value |
| -------------------------- | --------------------------- | ------------- | -------- | ------------- |
| [`new page`](#notion-page) | The new page to be created. | `notion page` | Yes      | (no default)  |

**Output Concepts**

| Concept                    | Description | Type          |
| -------------------------- | ----------- | ------------- |
| [`new page`](#notion-page) | None        | `notion page` |

**Examples**

Create a new minimal page in Notion

```generic
create a json
use the above as the parent
the  parent's page_id is "1de281a74b61808fbf0ce51553cb9ed2"
get '{"title": [{"text": {"content": "Minimal Page"}}]}' as a json
use the above as the properties body
get '[{"object":"block","type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"This is a simple paragraph."}}]}}]' as json
use the above as the blocks
the blocks
create a json
use the above as the page
the page's parent is the parent
the page's "properties" is the properties body
set the page's "children" to the blocks
the page
use the page as the new page
create the new page in notion
```

### to query some (pages) from *notion*

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Retrieves pages from Notion.

It will return a list of NotionPage objects, that are BDK representations of the Notion Page model.

**Input Concepts**

| Concept      | Description                                       | Type   | Required | Default Value |
| ------------ | ------------------------------------------------- | ------ | -------- | ------------- |
| `query text` | The text to search for in the title of the pages. | `text` | No       | (no default)  |

**Output Concepts**

| Concept                 | Description  | Type          |
| ----------------------- | ------------ | ------------- |
| [`pages`](#notion-page) | Notion Pages | `notion page` |

**Examples**

Query pages from notion Query pages from notion with a query text the query text is "BDK Test Page"

```generic
query some pages from notion
query some pages from notion
```

## Concepts

### Notion page

A dataclass representing a new Notion page.

| Field Name   | Description                        | Type                                                                                     |
| ------------ | ---------------------------------- | ---------------------------------------------------------------------------------------- |
| `parent`     | The parent of the Notion page.     | `or` or `or`                                                                             |
| `properties` | The properties of the Notion page. | `json`                                                                                   |
| `id`         | The ID of the Notion page.         | `optional[text]`                                                                         |
| `children`   | The children of the Notion page.   | `notion bulleted list item block?]` or `optional[list of list of notion paragraph block` |
