Skip to main content
Notion is a powerful workspace management tool that allows you to create, organize, and collaborate on your work. Agno provides tools for interacting with Notion databases to help you automate your workflows and streamline your work.

Prerequisites

To use NotionTools, you need to install notion-client:
pip install notion-client

Step 1: Create a Notion Integration

  1. Go to https://www.notion.so/my-integrations
  2. Click on ”+ New integration”
  3. Fill in the details:
    • Name: Give it a name like “Agno Query Classifier”
    • Associated workspace: Select your workspace
    • Type: Internal integration
  4. Click “Submit”
  5. Copy the “Internal Integration Token” (starts with secret_)
    • ⚠️ Keep this secret! This is your NOTION_API_KEY

Step 2: Create a Notion Database

  1. Open Notion and create a new page
  2. Add a Database (you can use “/database” command)
  3. 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

  1. Open your database page in Notion
  2. Click the ”…” (three dots) menu in the top right
  3. Scroll down and click “Add connections”
  4. Search for your integration name (e.g., “Agno Query Classifier”)
  5. Click on it to grant access

Step 4: Get Your Database ID

Your database ID is in the URL of your database page:
https://www.notion.so/../{database_id}?v={view_id}
The database_id is the 32-character string (with hyphens) between the workspace name and the ?v=. Example:
https://www.notion.so/myworkspace/28fee27fd9128039b3f8f47cb7ade7cb?v=...
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                 This is your database_id
Copy this database ID.
export NOTION_API_KEY=your_api_key_here
export NOTION_DATABASE_ID=your_database_id_here

Example

The following example demonstrates how to use NotionTools to create, update and search for Notion pages with specific tags.
from agno.agent import Agent
from agno.tools.notion import NotionTools

# Create an agent with Notion Tools
notion_agent = Agent(
    name="Notion Knowledge Manager",
    instructions=[
        "You are a smart assistant that helps organize information in Notion.",
        "When given content, analyze it and categorize it appropriately.",
        "Available categories: travel, tech, general-blogs, fashion, documents",
        "Always search first to avoid duplicate pages with the same tag.",
        "Be concise and helpful in your responses.",
    ],
    tools=[NotionTools()],
    markdown=True,
)


def demonstrate_tools():
    print("  Notion Tools Demonstration\n")
    print("=" * 60)

    # Example 1: Travel Notes
    print("\n Example 1: Organizing Travel Information")
    print("-" * 60)
    prompt = """
    I found this amazing travel guide: 
    'Ha Giang Loop in Vietnam - 4 day motorcycle adventure through stunning mountains.
    Best time to visit: October to March. Must-see spots include Ma Pi Leng Pass.'
    
    Save this to Notion under the travel category.
    """
    notion_agent.print_response(prompt)

    # Example 2: Tech Bookmarks
    print("\n Example 2: Saving Tech Articles")
    print("-" * 60)
    prompt = """
    Save this tech article to Notion:
    'The Rise of AI Agents in 2025 - How autonomous agents are revolutionizing software development.
    Key trends include multi-agent systems, agentic workflows, and AI-powered automation.'
    
    Categorize this appropriately and add to Notion.
    """
    notion_agent.print_response(prompt)

    # Example 3: Multiple Items
    print("\n Example 3: Batch Processing Multiple Items")
    print("-" * 60)
    prompt = """
    I need to save these items to Notion:
    1. 'Best fashion trends for spring 2025 - Sustainable fabrics and minimalist designs'
    2. 'My updated resume and cover letter for job applications'
    3. 'Quick thoughts on productivity hacks for remote work'
    
    Process each one and save them to the appropriate categories.
    """
    notion_agent.print_response(prompt)

    # Example 4: Search and Update
    print("\n🔍 Example 4: Finding and Updating Existing Content")
    print("-" * 60)
    prompt = """
    Search for any pages tagged 'tech' and let me know what you find.
    Then add this new insight to one of them:
    'Update: AI agents now support structured output with Pydantic models for better type safety.'
    """
    notion_agent.print_response(prompt)

    # Example 5: Smart Categorization
    print("\n Example 5: Automatic Smart Categorization")
    print("-" * 60)
    prompt = """
    I have this content but I'm not sure where it belongs:
    'Exploring the ancient temples of Angkor Wat in Cambodia. The sunrise view from Angkor Wat 
    is breathtaking. Best visited during the dry season from November to March.'
    
    Analyze this content, decide the best category, and save it to Notion.
    """
    notion_agent.print_response(prompt)

    print("\n" + "=" * 60)
    print(
        "\nYour Notion database now contains organized content across different categories."
    )
    print("Check your Notion workspace to see the results!")


if __name__ == "__main__":
    demonstrate_tools()

Toolkit Functions

These are the functions exposed by NotionTools:
FunctionDescription
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 the NotionTools constructor:
ParameterTypeDefaultDescription
api_keyOptional[str]NoneNotion API key (integration token). Uses NOTION_API_KEY env var if not provided.
database_idOptional[str]NoneThe ID of the database to work with. Uses NOTION_DATABASE_ID env var if not provided.
enable_create_pageboolTrueEnable the create_page tool.
enable_update_pageboolTrueEnable the update_page tool.
enable_search_pagesboolTrueEnable the search_pages tool.
allboolFalseEnable all tools. Overrides individual enable flags when True.

Developer Resources