Notion automation

From aAAaqwq/AGI-Super-Team · View interactive version

Notion automation is an AI agent skill from the GitHub repository aAAaqwq/AGI-Super-Team. 自动化 Notion 操作。当用户需要管理 Notion 页面、数据库、块内容、项目跟踪或进行内容组织和搜索时使用此技能。

How to use this skill

Skill file

Notion 自动化管理

功能说明

此技能专门用于自动化 Notion 平台的各种操作,包括:

使用场景

核心功能模块

1. 页面管理

2. 数据库管理

3. 块(Block)操作

4. 内容搜索

5. 协作管理

6. 项目管理

工作流程

标准页面创建流程

  1. 创建页面:创建新页面并设置标题
  2. 添加封面:设置页面封面图片
  3. 添加图标:设置页面图标
  4. 填充内容:使用块添加初始内容
  5. 关联数据库:如需要,关联到数据库
  6. 添加协作人:设置页面协作者

数据库设置流程

  1. 创建数据库:创建新数据库
  2. 定义字段:配置属性类型(文本、数字、日期等)
  3. 设置视图:创建不同视图(表格、看板、日历)
  4. 添加记录:批量添加初始记录
  5. 配置筛选:设置常用筛选条件
  6. 设置模板:创建页面模板

内容更新流程

  1. 获取当前内容:读取页面块结构
  2. 定位目标块:找到需要更新的块
  3. 更新块内容:修改块文本或属性
  4. 添加新块:如需要,插入新内容块
  5. 验证更新:确认更改正确应用

项目跟踪流程

  1. 创建项目数据库:建立项目看板
  2. 定义任务状态:设置状态字段(待办、进行中、已完成)
  3. 添加任务:创建任务记录
  4. 分配负责人:设置任务负责人
  5. 设置截止日期:添加日期字段
  6. 更新进度:随进度更新状态

最佳实践

页面组织

数据库设计

内容编辑

协作规范

常用代码示例

1. 创建页面并添加内容

// 创建新页面
const page = await createPage({
  parent: {
    type: "page_id",
    page_id: "parent_page_id"
  },
  properties: {
    title: {
      type: "title",
      title: [
        {
          type: "text",
          text: {
            content: "项目文档"
          }
        }
      ]
    }
  },
  children: [
    {
      object: "block",
      type: "paragraph",
      paragraph: {
        rich_text: [
          {
            type: "text",
            text: {
              content: "这是项目文档的概述内容。"
            }
          }
        ]
      }
    }
  ],
  icon: {
    type: "emoji",
    emoji: "📝"
  },
  cover: {
    type: "external",
    external: {
      url: "https://example.com/cover.jpg"
    }
  }
});

2. 数据库操作

// 创建数据库
const database = await createDatabase({
  parent: {
    type: "page_id",
    page_id: "parent_page_id"
  },
  title: [
    {
      type: "text",
      text: {
        content: "项目管理数据库"
      }
    }
  ],
  properties: {
    "任务名称": {
      title: {}
    },
    "状态": {
      select: {
        options: [
          { name: "待办", color: "gray" },
          { name: "进行中", color: "blue" },
          { name: "已完成", color: "green" }
        ]
      }
    },
    "负责人": {
      people: {}
    },
    "截止日期": {
      date: {}
    }
  }
});

// 查询数据库记录
const records = await queryDatabase({
  database_id: "database_id",
  filter: {
    property: "状态",
    select: {
      equals: "进行中"
    }
  },
  sorts: [
    {
      property: "截止日期",
      direction: "ascending"
    }
  ]
});

3. 页面搜索

// 搜索页面
const searchResults = await search({
  query: "项目计划",
  filter: {
    property: "object",
    value: "page"
  },
  sort: {
    direction: "descending",
    timestamp: "last_edited_time"
  }
});

// 搜索数据库
const dbResults = await search({
  query: "任务",
  filter: {
    property: "object",
    value: "database"
  }
});

4. 块内容更新

// 获取页面块
const blocks = await getBlockChildren({
  block_id: "page_id"
});

// 更新块内容
await updateBlock({
  block_id: "block_id",
  paragraph: {
    rich_text: [
      {
        type: "text",
        text: {
          content: "更新后的内容"
        }
      }
    ]
  }
});

// 添加新块
await appendBlockChildren({
  block_id: "parent_block_id",
  children: [
    {
      object: "block",
      type: "heading_2",
      heading_2: {
        rich_text: [
          {
            type: "text",
            text: {
              content: "新的章节标题"
            }
          }
        ]
      }
    }
  ]
});

5. 评论管理

// 创建评论
await createComment({
  parent: {
    page_id: "page_id"
  },
  rich_text: [
    {
      type: "text",
      text: {
        content: "建议在这里添加更多细节描述。"
      }
    }
  ]
});

// 获取评论
const comments = await retrieveComments({
  block_id: "page_id"
});

6. 页面移动

// 移动页面到其他父页面
await movePage({
  page_id: "page_id",
  parent: {
    type: "page_id",
    page_id: "new_parent_id"
  }
});

// 或移动到数据库
await movePage({
  page_id: "page_id",
  parent: {
    type: "database_id",
    database_id: "database_id"
  }
});

7. 批量操作

// 批量创建页面记录
const batchCreate = async (databaseId, records) => {
  for (const record of records) {
    await createPage({
      parent: {
        type: "database_id",
        database_id: databaseId
      },
      properties: {
        "任务名称": {
          title: [{ text: { content: record.title } }]
        },
        "状态": {
          select: { name: record.status }
        }
      }
    });
  }
};

// 批量更新块
const batchUpdate = async (updates) => {
  for (const update of updates) {
    await updateBlock({
      block_id: update.blockId,
      ...update.content
    });
  }
};

8. 用户和权限

// 获取用户信息
const users = await listUsers();

// 获取特定用户
const user = await getUser({
  user_id: "user_id"
});

// 获取当前用户
const me = await getSelf();

集成场景

1. 项目管理系统

2. 知识库管理

3. 内容创作工作流

4. 团队协作平台

5. 自动化报告生成

注意事项

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.