notion-core-workflow-b
Work with Notion blocks, rich text, comments, and page content. Use when reading/writing page content blocks, building rich text, managing comments, or working with nested block trees. Trigger with phrases like "notion blocks", "notion page content", "notion rich text", "notion comments", "notion append blocks".
What this skill does
# Notion Core Workflow B โ Blocks, Content & Comments
## Overview
Secondary workflow for content operations: reading block trees, appending content, building rich text with annotations, and managing comments.
## Prerequisites
- Completed `notion-install-auth` setup
- A Notion page shared with your integration
- Familiarity with `notion-core-workflow-a` (databases/pages)
## Instructions
### Step 1: Retrieve Block Children
```typescript
import { Client } from '@notionhq/client';
const notion = new Client({ auth: process.env.NOTION_TOKEN });
async function getPageContent(pageId: string) {
const blocks = [];
let cursor: string | undefined;
do {
const response = await notion.blocks.children.list({
block_id: pageId,
start_cursor: cursor,
page_size: 100,
});
blocks.push(...response.results);
cursor = response.has_more ? response.next_cursor ?? undefined : undefined;
} while (cursor);
return blocks;
}
```
### Step 2: Read Blocks Recursively (Nested Content)
```typescript
async function getBlockTree(blockId: string, depth = 0): Promise<any[]> {
const blocks = await getPageContent(blockId);
const tree = [];
for (const block of blocks) {
const node: any = { ...block, children: [] };
// Recursively fetch children if block has them
if ('has_children' in block && block.has_children) {
node.children = await getBlockTree(block.id, depth + 1);
}
tree.push(node);
}
return tree;
}
// Extract plain text from a block tree
function blockToText(block: any): string {
const type = block.type;
if (block[type]?.rich_text) {
return block[type].rich_text.map((t: any) => t.plain_text).join('');
}
return '';
}
```
### Step 3: Append Content Blocks
```typescript
async function appendContent(pageId: string) {
await notion.blocks.children.append({
block_id: pageId,
children: [
// Heading
{
heading_1: {
rich_text: [{ text: { content: 'Section Title' } }],
},
},
// Paragraph with formatting
{
paragraph: {
rich_text: [
{ text: { content: 'Regular text, ' } },
{ text: { content: 'bold' }, annotations: { bold: true } },
{ text: { content: ', ' } },
{ text: { content: 'italic' }, annotations: { italic: true } },
{ text: { content: ', ' } },
{ text: { content: 'code' }, annotations: { code: true } },
{ text: { content: ', and ' } },
{
text: { content: 'a link', link: { url: 'https://notion.so' } },
annotations: { underline: true },
},
],
},
},
// Bulleted list items
{
bulleted_list_item: {
rich_text: [{ text: { content: 'First bullet point' } }],
},
},
{
bulleted_list_item: {
rich_text: [{ text: { content: 'Second bullet point' } }],
},
},
// Numbered list
{
numbered_list_item: {
rich_text: [{ text: { content: 'Step one' } }],
},
},
// To-do items
{
to_do: {
rich_text: [{ text: { content: 'Task to complete' } }],
checked: false,
},
},
{
to_do: {
rich_text: [{ text: { content: 'Already done' } }],
checked: true,
},
},
// Code block
{
code: {
rich_text: [{ text: { content: 'console.log("Hello Notion!");' } }],
language: 'typescript',
},
},
// Callout
{
callout: {
rich_text: [{ text: { content: 'Important note here' } }],
icon: { emoji: '๐ก' },
},
},
// Quote
{
quote: {
rich_text: [{ text: { content: 'A meaningful quote' } }],
},
},
// Divider
{ divider: {} },
// Toggle block (with children added separately)
{
toggle: {
rich_text: [{ text: { content: 'Click to expand' } }],
},
},
],
});
}
```
### Step 4: Rich Text Annotations Reference
```typescript
// All annotation options
interface Annotations {
bold: boolean;
italic: boolean;
strikethrough: boolean;
underline: boolean;
code: boolean;
color: 'default' | 'gray' | 'brown' | 'orange' | 'yellow' |
'green' | 'blue' | 'purple' | 'pink' | 'red' |
'gray_background' | 'brown_background' | 'orange_background' |
'yellow_background' | 'green_background' | 'blue_background' |
'purple_background' | 'pink_background' | 'red_background';
}
// Rich text types: text, mention, equation
const richTextExamples = [
// Plain text
{ text: { content: 'Hello' } },
// Text with link
{ text: { content: 'Click here', link: { url: 'https://notion.so' } } },
// Mention a user
{ mention: { user: { id: 'user-uuid' } } },
// Mention a page
{ mention: { page: { id: 'page-uuid' } } },
// Mention a date
{ mention: { date: { start: '2026-04-01' } } },
// Inline equation (LaTeX)
{ equation: { expression: 'E = mc^2' } },
];
```
### Step 5: Update and Delete Blocks
```typescript
// Update a block's content
async function updateBlock(blockId: string) {
await notion.blocks.update({
block_id: blockId,
paragraph: {
rich_text: [{ text: { content: 'Updated content' } }],
},
});
}
// Delete (archive) a block
async function deleteBlock(blockId: string) {
await notion.blocks.delete({ block_id: blockId });
}
```
### Step 6: Work with Comments
```typescript
// Add a comment to a page
async function addComment(pageId: string, text: string) {
await notion.comments.create({
parent: { page_id: pageId },
rich_text: [{ text: { content: text } }],
});
}
// Add a comment to a specific block (discussion thread)
async function addBlockComment(discussionId: string, text: string) {
await notion.comments.create({
discussion_id: discussionId,
rich_text: [{ text: { content: text } }],
});
}
// List comments on a block or page
async function listComments(blockId: string) {
const response = await notion.comments.list({ block_id: blockId });
for (const comment of response.results) {
const text = comment.rich_text.map(t => t.plain_text).join('');
console.log(`${comment.created_by.id}: ${text}`);
}
}
```
## Output
- Page content blocks retrieved (flat or recursive tree)
- Rich content appended with formatting, lists, code, callouts
- Blocks updated and deleted
- Comments created and listed
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `validation_error` on append | Invalid block type structure | Check block type object shape |
| `object_not_found` | Block deleted or page not shared | Verify block ID and permissions |
| `rate_limited` (429) | Rapid block operations | Add delays between batch operations |
| Empty `rich_text` array | Block has no text content | Check block type before accessing |
## Examples
### Build a Report Page
```typescript
async function buildReport(pageId: string, data: { title: string; items: string[] }) {
const blocks: any[] = [
{ heading_1: { rich_text: [{ text: { content: data.title } }] } },
{ paragraph: { rich_text: [{ text: { content: `Generated ${new Date().toISOString()}` } }] } },
{ divider: {} },
];
for (const item of data.items) {
blocks.push({
bulleted_list_item: { rich_text: [{ text: { content: item } }] },
});
}
await notion.blocks.children.append({ block_id: pageId, children: blocks });
}
```
## Resources
- [Block Object Reference](https://developers.notion.com/reference/block)
- [Rich Text Reference](https://developers.notion.com/reference/rich-text)
- [Append Block Children](https://developers.notion.com/reference/patch-block-children)
- [Working with Page Content](https://developers.notion.com/docs/working-with-page-content)
- [Working with Comments](https://developRelated in Productivity
gitea-workflow
IncludedOrchestrate agile development workflows for Gitea repositories using the tea CLI. Use when working with Gitea-hosted repos and asking to 'run the workflow', 'continue working', 'what's next', 'complete the task cycle', 'start my day', 'end the sprint', 'implement the next task', or wanting guided step-by-step development assistance. Keywords: workflow, orchestrate, agile, task cycle, sprint, daily, implement, review, PR, standup, retrospective, gitea, tea.
microsoft-graph-gateway
IncludedRoute Microsoft Graph work in this workspace. Use when users want to read or write Outlook mail, calendar events, contacts, OneDrive or SharePoint files, Teams, Planner, To Do, users, groups, directory data, or arbitrary Microsoft Graph endpoints from VS Code. Prefer WorkIQ for common read scenarios. Use Microsoft Graph for write actions and gap-read scenarios that need exact Graph properties, filters, permissions, or endpoints.
copilotkit
IncludedUse when building with CopilotKit โ setup, development, integrations, debugging, upgrading, or contributing. Routes to the appropriate specialized skill based on the task.
wordly-wisdom
IncludedProvides calibrated decision analysis using Charlie Munger-style multiple mental models, inversion, incentive mapping, circle-of-competence checks, misjudgment audits, second-order effects, and forecast updates. Use when the user asks for an oracle take, a hard call, a decision memo, a premortem, an outside view, a red-team, a sanity-check, what am I missing, think this through, or wants a strategy, hire, investment, plan, product, partnership, or major life choice analysed. Avoid for simple factual lookups or time-sensitive legal, medical, or market questions without fresh evidence.
swain-session
IncludedSession management and project status dashboard. Owns the full session lifecycle (start/work/close/resume), focus lane, bookmarks, worktree detection, and tab naming. Also serves as the project status dashboard โ shows active epics, progress, actionable next steps, blocked items, tasks, GitHub issues, and recommendations. Worktree creation is deferred to swain-do task dispatch (SPEC-195). Triggers on: 'session', 'status', 'what's next', 'dashboard', 'overview', 'where are we', 'what should I work on', 'show me priorities', 'bookmark', 'focus on', 'session info'.
gandi
IncludedComprehensive Gandi domain registrar integration for domain and DNS management. Register and manage domains, create/update/delete DNS records (A, AAAA, CNAME, MX, TXT, SRV, and more), configure email forwarding and aliases, check SSL certificate status, create DNS snapshots for safe rollback, bulk update zone files, and monitor domain expiration. Supports multi-domain management, zone file import/export, and automated DNS backups. Includes both read-only and destructive operations with safety controls.