网淘吧来吧,欢迎您!

Notion Enhanced技能使用说明

2026-03-30 新闻来源:网淘吧 围观:9
电脑广告
手机广告

Notion集成

将您的Notion工作空间连接到OpenClaw,实现无缝知识管理和项目追踪。

何时使用此技能

当用户希望进行以下操作时,请使用Notion:

Notion Enhanced

  • 向数据库添加项目(如待办事项、任务列表、追踪项)
  • 创建新页面在数据库中或作为现有页面的子页面
  • 查询/搜索其Notion工作空间中的信息
  • 更新现有页面(状态、笔记、属性)
  • 读取页面内容或数据库条目

设置

1. 创建Notion集成

  1. 访问notion.so/my-integrations
  2. 点击新建集成
  3. 为其命名(例如"OpenClaw")
  4. 选择您的工作空间
  5. 复制内部集成令牌(以secret_开头)
  6. 请将此令牌安全地保存在 OpenClaw 配置或环境中:NOTION_TOKEN=secret_...

2. 与集成共享页面

重要提示:Notion 集成默认没有访问权限。您必须显式共享:

  1. 转到 Notion 中的任意页面或数据库
  2. 点击共享添加连接
  3. 选择您的 "OpenClaw" 集成
  4. 该技能现在可以对该特定页面/数据库进行读取/写入

3. 获取数据库/页面 ID

从 URL 中获取:

  • 数据库:https://www.notion.so/workspace/XXXXXXXX?v=...→ ID 为XXXXXXXX(32 个字符)
  • 页面:https://www.notion.so/workspace/XXXXXXXX→ ID 是XXXXXXXX

注意:使用 ID 时请移除连字符。使用 32 个字符的字符串。

核心操作

查询数据库

从您已共享的任何数据库中检索条目。

// Using the Notion skill via exec
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js query-database ${databaseId}`
});

// With filters (example: status = "In Progress")
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js query-database ${databaseId} --filter '{"property":"Status","select":{"equals":"In Progress"}}'`
});

返回:页面数组,其属性按照您数据库中的配置。

添加数据库条目

在数据库中创建新行。

// Add entry with multiple properties
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js add-entry ${databaseId} \
    --title "My New Content Idea" \
    --properties '${JSON.stringify({
      "Status": { "select": { "name": "Idea" } },
      "Platform": { "multi_select": [{ "name": "X/Twitter" }] },
      "Tags": { "multi_select": [{ "name": "3D Printing" }, { "name": "AI" }] },
      "Priority": { "select": { "name": "High" } }
    })}'`
});

获取页面内容

读取任何页面(包括数据库条目)的内容。

await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js get-page ${pageId}`
});

返回:页面标题、属性以及区块内容(文本、标题、列表等)。

更新页面

修改现有页面的属性或追加内容。

// Update properties
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js update-page ${pageId} \
    --properties '${JSON.stringify({
      "Status": { "select": { "name": "In Progress" } }
    })}'`
});

// Append content blocks
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js append-body ${pageId} \
    --text "Research Notes" --type h2`
});

搜索 Notion

在您共享的工作区内查找页面。

await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js search "content ideas"`
});

常见使用场景

内容管线(内容创作者工作流)

数据库结构:

  • 标题 (title)
  • 状态 (select: 构思 → 草稿 → 已排期 → 已发布)
  • 平台 (multi_select: X/Twitter, YouTube, MakerWorld, 博客)
  • 发布日期 (date)
  • 标签 (multi_select)
  • 草稿内容 (rich_text)

OpenClaw集成:

// Research scout adds findings to Notion
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js add-entry ${contentDbId} \
    --title "New 3D Print Technique" \
    --properties '${JSON.stringify({
      "Status": { "select": { "name": "Idea" } },
      "Platform": { "multi_select": [{ "name": "YouTube" }] },
      "Tags": { "multi_select": [{ "name": "3D Printing" }] }
    })}'`
});

// Later: Update when drafting
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js update-page ${entryId} \
    --properties '${JSON.stringify({
      "Status": { "select": { "name": "Draft" } },
      "Draft Content": { "rich_text": [{ "text": { "content": "Draft text here..." } }] }
    })}'`
});

项目管理(独立创业者)

数据库结构:

  • 名称 (title)
  • 状态 (select: 未开始 → 进行中 → 受阻 → 已完成)
  • 优先级 (select: 低 → 中 → 高 → 紧急)
  • 截止日期 (date)
  • 预估工时 (number)
  • 实际工时 (number)
  • 相关链接 (url)
  • 备注 (rich_text)

周度复盘集成:

// Query all "In Progress" projects
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js query-database ${projectsDbId} --filter '{"property":"Status","select":{"equals":"In Progress"}}'`
});

客户/报价 CRM(3D打印业务)

数据库结构:

  • 客户名称(标题)
  • 状态(选择:潜在客户 → 报价已发送 → 已下单 → 打印中 → 已发货)
  • 邮箱(电子邮件)
  • 报价金额(数字)
  • 线材类型(选择)
  • 截止日期(日期)
  • Shopify订单ID(富文本)

Shopify集成:

// New order → create CRM entry
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js add-entry ${crmDbId} \
    --title "${customerName}" \
    --properties '${JSON.stringify({
      "Status": { "select": { "name": "Ordered" } },
      "Email": { "email": customerEmail },
      "Shopify Order ID": { "rich_text": [{ "text": { "content": orderId } }] }
    })}'`
});

知识库(用于替代MEMORY.md的维基)

结构:包含嵌套页面的中心页面:

  • 🏠 主页(与集成共享)
    • 标准操作程序
    • 故障排除
    • 设计模式
    • 资源链接

用于快速参考的查询:

// Search for "stringing" to find 3D print troubleshooting
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js search "stringing"`
});

属性类型参考

创建/更新数据库条目时,请使用以下属性值格式:

// Title (always required for new pages)
{ "title": [{ "text": { "content": "Page Title" } }] }

// Select (single choice)
{ "select": { "name": "Option Name" } }

// Multi-select (multiple choices)
{ "multi_select": [{ "name": "Tag 1" }, { "name": "Tag 2" }] }

// Status (for new Status property type)
{ "status": { "name": "In progress" } }

// Text / Rich text
{ "rich_text": [{ "text": { "content": "Your text here" } }] }

// Number
{ "number": 42 }

// Date
{ "date": { "start": "2026-02-15" } }
{ "date": { "start": "2026-02-15T10:00:00", "end": "2026-02-15T12:00:00" } }

// Checkbox
{ "checkbox": true }

// Email
{ "email": "user@example.com" }

// URL
{ "url": "https://example.com" }

// Phone
{ "phone_number": "+1-555-123-4567" }

// Relation (link to another database entry)
{ "relation": [{ "id": "related-page-id-32chars" }] }

安全与权限

关键安全模型:

  • ✅ 集成仅能访问您明确分享的页面
  • ✅ 您可按页面/数据库控制访问权限
  • ✅ 令牌安全存储于~/.openclaw/.env(绝不存储在代码中)
  • ❌ 切勿将NOTION_TOKEN提交至 git
  • ❌ 集成无法访问私人团队空间或其他用户的私人页面

最佳实践:

  1. 使用专用集成(勿复用个人集成)
  2. 仅分享必要的最小页面范围(精细控制优于宽泛授权)
  3. 若凭证泄露,请通过Notion集成设置轮换令牌
  4. 定期检查已分享的连接

环境设置

添加到~/.openclaw/.env

NOTION_TOKEN=secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

或按命令设置:

NOTION_TOKEN=secret_xxx node notion-cli.js ...

错误处理

常见错误及修复方法:

错误原因修复方法
"API令牌无效"令牌错误或集成已被删除在 notion.so/my-integrations 检查令牌
"对象未找到"页面未与集成共享分享页面:分享 → 添加连接
"验证错误"属性格式不正确检查数据库中的属性类型
"请求频率受限"请求过多在请求之间添加延迟

快速安装(一条命令)

cd ~/.agents/skills/notion
./install.sh

手动安装(如果上述方法失败):

cd ~/.agents/skills/notion
npm install

就是这样!独立版本无需构建步骤。

快速测试

# After setting NOTION_TOKEN in ~/.openclaw/.env
node notion-cli.js test

智能ID解析

通过以下方式引用条目Notion 自动ID(例如,#3) 或直接UUID.

通过Notion ID(推荐手动使用)

使用您在数据库ID列中看到的数字:

# Get entry #3
node notion-cli.js get-page '#3' DATABASE_ID

# Add content to entry #3
node notion-cli.js append-body '#3' --database DATABASE_ID \
  --text "Research notes" --type h2

# Add bullet to entry #3
node notion-cli.js append-body '#3' --database DATABASE_ID \
  --text "Key finding" --type bullet

通过直接UUID(用于自动化)

# Using full UUID from Notion URL
node notion-cli.js get-page 2fb3e4ac...
node notion-cli.js append-body 2fb3e4ac... \
  --text "Content" --type paragraph

自动检测:#开头 = Notion ID查找。32个字符的十六进制 = 直接UUID。

专业提示:添加一个ID属性(类型:唯一ID)以自动为条目编号为#1、#2、#3...

页面正文编辑

向页面正文添加富文本内容,而不仅仅是属性。

追加内容块

# Add heading
node notion-cli.js append-body PAGE_ID --text "Research Summary" --type h2

# Add paragraph (default)
node notion-cli.js append-body PAGE_ID --text "Detailed findings go here..."

# Add bullet list item
node notion-cli.js append-body PAGE_ID --text "First key finding" --type bullet

# Add numbered list item
node notion-cli.js append-body PAGE_ID --text "Step one description" --type numbered

# Add TODO checkbox
node notion-cli.js append-body PAGE_ID --text "Create video script" --type todo

# Add quote
node notion-cli.js append-body PAGE_ID --text "Important quote from source" --type quote

# Add code block
node notion-cli.js append-body PAGE_ID --text "const result = optimizeSupports();" --type code --lang javascript

支持的块类型

类型描述使用示例
段落常规文本(默认)描述,解释
一级标题二级标题三级标题标题章节组织
项目符号项目符号列表关键发现,特性
编号编号列表逐步说明
待办事项复选框项目行动项目,任务
引用块引用来源引用
代码代码块代码片段,命令
分割线水平线章节分隔

获取包含正文内容的页面

# Get full page including formatted body
node notion-cli.js get-page PAGE_ID

返回:

  • 页面属性
  • 格式化的正文块(类型 + 内容预览)
  • 块数量

高级:原始 JSON 块

对于复杂布局,使用原始 Notion 块 JSON:

node notion-cli.js append-body PAGE_ID --blocks '[
  {"object":"block","type":"heading_2","heading_2":{"rich_text":[{"text":{"content":"Research Notes"}}]}},
  {"object":"block","type":"bulleted_list_item","bulleted_list_item":{"rich_text":[{"text":{"content":"Finding 1"}}]}},
  {"object":"block","type":"code","code":{"rich_text":[{"text":{"content":"console.log(1)"}}],"language":"javascript"}}
]'

高级:Webhook 同步

用于双向同步(Notion 变更 → OpenClaw):

  1. 设置 Notion webhook 集成(需要 Notion 合作伙伴账户)
  2. 将 webhook 端点配置到您的 OpenClaw 网关
  3. 技能处理传入的 webhook 并更新内存文件

参见references/webhooks.md了解实施细节。


需要帮助?在以下位置检查您的 Notion 集成设置:https://www.notion.so/my-integrations

在 OpenClaw 中使用

快速设置

# 1. Install
cd ~/.agents/skills/notion
npm install

# 2. Configure token
echo "NOTION_TOKEN=secret_xxxxxxxxxx" >> ~/.openclaw/.env

# 3. Test connection
node notion-cli.js test

从 OpenClaw Agent

// Query database
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js query-database YOUR_DB_ID`
});

// Add entry
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js add-entry YOUR_DB_ID \\
    --title "New Content Idea" \\
    --properties '{"Status":{"select":{"name":"Idea"}}}'`
});

// Search
await exec({
  command: `node ~/.agents/skills/notion/notion-cli.js search "tree support"`
});

Cron任务使用指南

更新您的Research Topic Scout以推送至Notion:

"message": "Research trends and add to Notion: 
  node ~/.agents/skills/notion/notion-cli.js add-entry DB_ID 
    --title '<title>' 
    --properties '{...,\"Platform\":{\"multi_select\":[{\"name\":\"X\"}]}}'"

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第340229名访客 今日有38篇新文章/评论