Loading...
Loading...
Automate Notion operations. This skill is used when users need to manage Notion pages, databases, block content, project tracking, or perform content organization and search.
npx skill4agent add aaaaqwq/claude-code-skills notion-automation// 创建新页面
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"
}
}
});// 创建数据库
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"
}
]
});// 搜索页面
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"
}
});// 获取页面块
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: "新的章节标题"
}
}
]
}
}
]
});// 创建评论
await createComment({
parent: {
page_id: "page_id"
},
rich_text: [
{
type: "text",
text: {
content: "建议在这里添加更多细节描述。"
}
}
]
});
// 获取评论
const comments = await retrieveComments({
block_id: "page_id"
});// 移动页面到其他父页面
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"
}
});// 批量创建页面记录
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
});
}
};// 获取用户信息
const users = await listUsers();
// 获取特定用户
const user = await getUser({
user_id: "user_id"
});
// 获取当前用户
const me = await getSelf();