OpenClaw + Notion Integration Guide
Overview
Connect your OpenClaw agent to Notion to enable powerful data management, journaling, and analysis capabilities. This integration allows your agent to read from and write to Notion databases, making it perfect for task management, knowledge bases, and data analysis.
Benefits
- Second Brain: Offload daily progress and reports to Notion for semantic search later
- Data Analysis: Analyze large datasets stored in Notion databases (trade journals, project data, etc.)
- Task Management: Automatically create and update tasks in Notion
- Cost Effective: Notion is free and provides robust database capabilities
- Organized Knowledge: Use Notion's multiple views (Kanban, Calendar, Table) to visualize data
Prerequisites
- OpenClaw 3.2 or later installed and running
- Notion account (free tier works)
- Terminal access to your OpenClaw installation (SSH, Termius, or local terminal)
- Basic understanding of environment variables
Step-by-Step Setup
Step 1: Create Notion Integration
- Navigate to notion.so/profile
- Click on "My integrations" in the left sidebar
- Click "+ New integration"
- Configure your integration:
- Name: Choose a descriptive name (e.g., "OpenClaw Agent")
- Associated workspace: Select your workspace
- Icon: Optional - upload an icon if desired
- Click "Submit" or "Create"
[Image blocked: Notion Integration Creation]
Step 2: Get Your API Secret
- After creating the integration, you'll see the integration settings page
- Under "Internal Integration Secret", click "Show"
- Click "Copy" to copy your secret token
- ⚠️ IMPORTANT: Keep this secret secure - never share it publicly
[Image blocked: Notion API Secret]
Step 3: Store API Key Securely in .env File
This is the proper way to store API keys - never paste them directly in Discord, WhatsApp, or other chat channels.
- Open your terminal and connect to your OpenClaw server
- Navigate to your OpenClaw directory
- Run this command to edit your environment file:
nano ~/.openclaw/.env
nano ~/.openclaw/.env
- Add your Notion API key:
NOTION_API_KEY=your_internal_integration_secret_here
NOTION_API_KEY=your_internal_integration_secret_here
- Save and exit:
- Press
Ctrl + X - Press
Yto confirm save - Press
Enterto confirm filename
- Press
[Image blocked: Environment Variable Setup]
Example:
NOTION_API_KEY=secret_abc123XYZ456def789GHI012jkl345MNO678pqr901STU234vwx567YZA890
NOTION_API_KEY=secret_abc123XYZ456def789GHI012jkl345MNO678pqr901STU234vwx567YZA890
Step 4: Connect Integration to Notion Database
- Open or create a database in Notion (e.g., "Trade Journal", "Task Manager", "Knowledge Base")
- Click the "..." menu in the top-right corner of the database
- Select "Connections" (or "Add connections")
- Scroll down and find your integration name (e.g., "OpenClaw Agent")
- Click "Connect"
[Image blocked: Connect Database]
Step 5: Configure Permissions (Optional)
If you want your agent to only read data (not write or modify):
- Go back to your integration settings at notion.so/my-integrations
- Click on your integration
- Scroll down to "Capabilities"
- Disable:
- "Update content"
- "Insert content"
- Keep "Read content" enabled
- Click "Save changes"
For full read/write access (recommended for task management), keep all capabilities enabled.
Configuration Examples
Read-Only Configuration (Data Analysis)
Perfect for analyzing existing data without modification:
# .env file
NOTION_API_KEY=your_secret_key_here
# .env file
NOTION_API_KEY=your_secret_key_here
Notion Integration Capabilities:
- ✅ Read content
- ❌ Update content
- ❌ Insert content
Full Access Configuration (Task Management)
Allows agent to create, read, and update:
# .env file
NOTION_API_KEY=your_secret_key_here
# .env file
NOTION_API_KEY=your_secret_key_here
Notion Integration Capabilities:
- ✅ Read content
- ✅ Update content
- ✅ Insert content
Usage Examples
Example 1: Data Analysis (Read-Only)
You: Hey agent, can you review my entire trade history in the BingX Trade Journal database and tell me how many trades closed in an hour or less?
Agent: I found 548 total trades in your journal. 365 of them (66.6%) were closed in an hour or less. That's an interesting pattern - about 2/3 of your trades are short-term positions.
You: Can you focus only on BTC, ETH, and SOL trades?
Agent: Out of the 548 trades, 466 were BTC, ETH, or SOL. That means only 82 trades (15%) were other tokens. Your portfolio is heavily focused on major cryptocurrencies.
You: Hey agent, can you review my entire trade history in the BingX Trade Journal database and tell me how many trades closed in an hour or less?
Agent: I found 548 total trades in your journal. 365 of them (66.6%) were closed in an hour or less. That's an interesting pattern - about 2/3 of your trades are short-term positions.
You: Can you focus only on BTC, ETH, and SOL trades?
Agent: Out of the 548 trades, 466 were BTC, ETH, or SOL. That means only 82 trades (15%) were other tokens. Your portfolio is heavily focused on major cryptocurrencies.
Example 2: Second Brain (Knowledge Management)
You: Upload today's research findings to my Knowledge Base in Notion
Agent: I've created a new entry in your Knowledge Base with today's date. The research on AI model optimization has been documented with key findings and references.
You: Can you search my past notes for anything related to "prompt engineering"?
Agent: I found 12 entries mentioning prompt engineering across your Knowledge Base. The most relevant ones are from March 2026 discussing few-shot learning techniques.
You: Upload today's research findings to my Knowledge Base in Notion
Agent: I've created a new entry in your Knowledge Base with today's date. The research on AI model optimization has been documented with key findings and references.
You: Can you search my past notes for anything related to "prompt engineering"?
Agent: I found 12 entries mentioning prompt engineering across your Knowledge Base. The most relevant ones are from March 2026 discussing few-shot learning techniques.
Example 3: Task Management
You: Create a task in Notion to review the Q2 financial reports by Friday
Agent: Task created in your Notion workspace:
- Title: Review Q2 Financial Reports
- Due Date: Friday, May 9, 2026
- Status: To Do
- Priority: High
You: Create a task in Notion to review the Q2 financial reports by Friday
Agent: Task created in your Notion workspace:
- Title: Review Q2 Financial Reports
- Due Date: Friday, May 9, 2026
- Status: To Do
- Priority: High
Security Best Practices
✅ DO:
- Store API keys in .env files - This is the proper, secure method
- Use read-only permissions when you only need to analyze data
- Revoke and regenerate tokens if they're accidentally exposed
- Keep your .env file in .gitignore to prevent committing secrets to version control
- Use separate integrations for different projects or agents
❌ DON'T:
- Never paste API keys in Discord, Slack, WhatsApp, or other chat platforms
- Never commit .env files to Git repositories
- Never share screenshots containing API secrets
- Don't use the same API key across multiple unrelated projects
- Don't give full write permissions if read-only access is sufficient
Environment Variable Security
The .env file approach is secure because:
- AI models are trained not to reveal environment variables - Your agent won't accidentally leak secrets
- File permissions - The .env file is only accessible to your user account
- Separation of concerns - Secrets are separate from code and chat logs
- Easy rotation - Update the .env file to rotate keys without changing code
Common Issues and Solutions
Issue 1: Agent Can't Access Notion Database
Symptoms:
- "I don't have access to that database"
- "Permission denied" errors
Solution:
- Verify the database is connected to your integration (Step 4)
- Check that the integration has the correct capabilities enabled
- Ensure the API key in .env matches your integration secret
Issue 2: API Key Not Found
Symptoms:
- "NOTION_API_KEY environment variable not set"
- Agent asks for API key repeatedly
Solution:
- Verify the .env file exists:
ls -la ~/.openclaw/.env - Check the key is properly formatted:
NOTION_API_KEY=secret_... - Restart OpenClaw gateway:
openclaw gateway restart_
Issue 3: Integration Secret Exposed
Symptoms:
- You accidentally shared your API key in a video, screenshot, or chat
Solution:
- Go to notion.so/my-integrations
- Click on your integration
- Under "Internal Integration Secret", click "Regenerate"
- Update your .env file with the new secret
- Restart OpenClaw gateway
Issue 4: Can't Edit .env File
Symptoms:
- "Permission denied" when trying to edit .env
- File doesn't exist
Solution:
# Create the directory if it doesn't exist
mkdir -p ~/.openclaw
# Create the .env file with proper permissions
touch ~/.openclaw/.env
chmod 600 ~/.openclaw/.env
# Now edit it
nano ~/.openclaw/.env
# Create the directory if it doesn't exist
mkdir -p ~/.openclaw
# Create the .env file with proper permissions
touch ~/.openclaw/.env
chmod 600 ~/.openclaw/.env
# Now edit it
nano ~/.openclaw/.env
Advanced Use Cases
Multi-Database Setup
Connect multiple Notion databases for different purposes:
- Tasks Database - Project management and to-dos
- Knowledge Base - Research notes and documentation
- Data Analysis - Trade journals, metrics, analytics
- Meeting Notes - Automatic meeting summaries
Each database can have different permissions and structures.
Semantic Search
Use Notion as a long-term memory for your agent:
You: Search my past 6 months of notes for anything about "machine learning optimization"
Agent: I found 23 relevant entries. The most important insights were:
1. Batch size optimization (March 15, 2026)
2. Learning rate scheduling techniques (April 2, 2026)
3. Gradient accumulation strategies (April 28, 2026)
You: Search my past 6 months of notes for anything about "machine learning optimization"
Agent: I found 23 relevant entries. The most important insights were:
1. Batch size optimization (March 15, 2026)
2. Learning rate scheduling techniques (April 2, 2026)
3. Gradient accumulation strategies (April 28, 2026)
Automated Reporting
Set up your agent to automatically log daily progress:
You: At the end of each day, summarize what we worked on and log it to my Daily Journal in Notion
Agent: I'll create a daily summary entry in your Notion journal every evening with:
- Tasks completed
- Key decisions made
- Blockers encountered
- Next steps planned
You: At the end of each day, summarize what we worked on and log it to my Daily Journal in Notion
Agent: I'll create a daily summary entry in your Notion journal every evening with:
- Tasks completed
- Key decisions made
- Blockers encountered
- Next steps planned
Related Guides
- Security Best Practices [blocked] - Comprehensive guide on API key management
- API Integration Guide [blocked] - Learn how to add other APIs to OpenClaw
- Discord Setup [blocked] - Set up Discord for team collaboration
- Telegram Setup [blocked] - Configure Telegram for mobile access
Troubleshooting Checklist
Before asking for help, verify:
- OpenClaw version is 3.2 or later (
openclaw --version) - Notion integration is created and secret is copied
- API key is stored in
~/.openclaw/.envwith correct format - Database is connected to your integration in Notion
- Integration has appropriate capabilities enabled
- OpenClaw gateway has been restarted after configuration
- No typos in environment variable name (
NOTION_API_KEY)
Additional Resources
Video Tutorial: Watch the full setup guide
Need Help? Join the OpenClaw community Discord or check the troubleshooting guide.