Skip to main content
Agent with Notion workspace integration.

Code

How It Works

Custom Tools
  • create_notion_page(): Creates pages in Notion
  • search_notion(): Searches database entries
  • Tools passed to agent via tools parameter
Notion Client
  • notion_client library for API access
  • Authenticated with NOTION_API_KEY
  • Targets specific database via NOTION_DATABASE_ID
Environment Variables
  • NOTION_API_KEY: Your Notion integration token
  • NOTION_DATABASE_ID: Target database ID
  • OPENROUTER_API_KEY: LLM access

Dependencies

Environment Setup

Create .env file:

Setup

  1. Create Notion integration at notion.so/my-integrations
  2. Share database with integration
  3. Copy database ID from URL

Run

Examples:
  • “Create a page titled ‘Meeting Notes’ with content ‘Discussed Q1 goals’”
  • “Add a task to my Notion database: ‘Review project documentation’”
  • “Create a database entry for ‘Client Meeting’ with status ‘In Progress‘“

Example API Calls

Frontend Setup

Open http://localhost:5173 and try to chat with Notion agent