Prerequisites
To useNotionTools, you need to install notion-client:
Step 1: Create a Notion Integration
- Go to https://www.notion.so/my-integrations
- Click on ”+ New integration”
- Fill in the details:
- Name: Give it a name like “Agno Query Classifier”
- Associated workspace: Select your workspace
- Type: Internal integration
- Click “Submit”
- Copy the “Internal Integration Token” (starts with
secret_)- ⚠️ Keep this secret! This is your
NOTION_API_KEY
- ⚠️ Keep this secret! This is your
Step 2: Create a Notion Database
- Open Notion and create a new page
- Add a Database (you can use “/database” command)
- Set up the database with these properties:
- Name (Title) - Already exists by default
- Tag (Select) - Click ”+” to add a new property
- Property type: Select
- Property name: Tag
- Add these options:
- travel
- tech
- general-blogs
- fashion
- documents
Step 3: Share Database with Your Integration
- Open your database page in Notion
- Click the ”…” (three dots) menu in the top right
- Scroll down and click “Add connections”
- Search for your integration name (e.g., “Agno Query Classifier”)
- Click on it to grant access
Step 4: Get Your Database ID
Your database ID is in the URL of your database page:database_id is the 32-character string (with hyphens) between the workspace name and the ?v=.
Example:
Example
The following example demonstrates how to useNotionTools to create, update and search for Notion pages with specific tags.
Toolkit Functions
These are the functions exposed byNotionTools:
| Function | Description |
|---|---|
create_page(title, tag, content) | Creates a new page in the Notion database with a title, tag, and content. |
update_page(page_id, content) | Adds content to an existing Notion page by appending a new paragraph. |
search_pages(tag) | Searches for pages in the database by tag and returns matching results. |
Toolkit Params
These parameters are passed to theNotionTools constructor:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Optional[str] | None | Notion API key (integration token). Uses NOTION_API_KEY env var if not provided. |
database_id | Optional[str] | None | The ID of the database to work with. Uses NOTION_DATABASE_ID env var if not provided. |
enable_create_page | bool | True | Enable the create_page tool. |
enable_update_page | bool | True | Enable the update_page tool. |
enable_search_pages | bool | True | Enable the search_pages tool. |
all | bool | False | Enable all tools. Overrides individual enable flags when True. |
Developer Resources
- View Tools