Notion: enrich pages with generated documentation
Example Workflows (Ready to Adapt) – Notion: Enrich Pages with Generated Documentation
This workflow demonstrates how to automatically enrich Notion pages containing code snippets. It fetches entries from a Notion database, generates comprehensive documentation via the DocuWriter.ai node, then appends generated content back to each Notion page.
Workflow Steps
- 📓 Get Notion Database
Retrieve pages from a specified Notion database. - 📝 Extract Code from Notion
Filter pages that include aCoderich-text property and prepare metadata for each. - 🤖 Generate Notion Documentation
Use the DocuWriter.ai action node to generate structured documentation for each code snippet. - 📎 Update Notion Page
Append a heading and the generated documentation back to the original Notion page.
Node Breakdown
| Node Name | Type | Purpose |
|---|---|---|
| Get Notion Database | n8n-nodes-base.notion | Fetches all pages from a Notion database by ID. |
| Extract Code from Notion | n8n-nodes-base.code | Parses each page’s properties to extract code snippets and related metadata. |
| Generate Notion Documentation | docuwriter-ai | Sends the code snippet to DocuWriter.ai to produce detailed documentation. |
| Update Notion Page | n8n-nodes-base.notion | Appends generated documentation blocks (heading and paragraphs) to the target Notion page. |
Configuration Details
1. Get Notion Database
{
"parameters": {
"authentication": "oAuth2",
"resource": "database",
"operation": "getMany",
"databaseId": "<YOUR_DATABASE_ID>",
"options": {}
}
}
2. Extract Code from Notion
This Code node scans each returned page, looks for a Code rich-text property, and emits items only for pages containing code.
// Node: Extract Code from Notion
const pages = $json.results || [];
const codePages = [];
for (const page of pages) {
const props = page.properties;
if (props['Code']?.rich_text?.length > 0) {
codePages.push({
json: {
notion: {
pageId: page.id,
fileName: props['Name']?.title?.[0]?.plain_text || 'Untitled',
language: props['Language']?.select?.name || 'text',
codeContent: props['Code'].rich_text[0].plain_text
}
}
});
}
}
return codePages;
3. Generate Notion Documentation
The DocuWriter.ai node takes the extracted code and generates structured documentation, formatted for Notion integration.
{
"parameters": {
"sourceCode": "={{ $json.notion.codeContent }}",
"generationType": "Documentation",
"mode": "accurate",
"additionalInstructions": "Create comprehensive documentation for {{ $json.notion.fileName }}. Include detailed explanations, usage examples, and best practices. Format for Notion page integration."
},
"type": "docuwriter-ai",
"name": "Generate Notion Documentation"
}
4. Update Notion Page
This Notion node appends blocks under each page with a heading and the generated documentation.
{
"parameters": {
"authentication": "oAuth2",
"resource": "block",
"operation": "append",
"pageId": "={{ $json.notion.pageId }}",
"blockUi": {
"blockValues": [
{
"type": "heading_2",
"rich_text": "📚 Generated Documentation"
},
{
"type": "paragraph",
"rich_text": "{{ $json.generatedContent }}"
},
{
"type": "paragraph",
"rich_text": "Generated by DocuWriter.ai on {{ new Date().toLocaleDateString() }}"
}
]
}
},
"type": "n8n-nodes-base.notion",
"name": "Update Notion Page"
}
Workflow Diagram
flowchart TD
A[Get Notion Database] --> B[Extract Code from Notion]
B --> C[Generate Notion Documentation]
C --> D[Update Notion Page]
style A fill:#f9f,stroke:#333,stroke-width:1px
style B fill:#ff9,stroke:#333,stroke-width:1px
style C fill:#9f9,stroke:#333,stroke-width:1px
style D fill:#9cf,stroke:#333,stroke-width:1px
Tips for Adaptation
- Batch Size: Limit the number of pages processed per run to manage rate limits.
- Error Handling: Add “IF” nodes to catch missing properties or API errors.
- Customization: Adjust
additionalInstructionsin the DocuWriter.ai node to tailor tone or format. - Scheduling: Use a Cron-trigger to run this enrichment at desired intervals.
This template provides a solid foundation to enrich Notion pages with AI-generated documentation, ready to adapt to your specific database schema and team requirements.
Updated