Notion IM Helper
by @70asunflower
Sync IM messages to Notion via Notion API. Supports 7 content types, 4 formats, 2 metadata types. Append-only to a single Notion page.
clawhub install notion-im-helper📖 About This Skill
name: notion-im-helper description: Sync IM messages to Notion via Notion API. Supports 7 content types, 4 formats, 2 metadata types. Append-only to a single Notion page.
Notion IM Helper
通过消息自动同步内容到 Notion。支持日记、笔记、待办、想法、问题、链接、摘抄 7 种类型。
Environment Variables
NOTION_API_KEY - Notion Integration TokenNOTION_PARENT_PAGE_ID - Target Notion Page ID (32 chars)NOTION_QUOTES_PAGE_ID (optional) - Separate page for quotesSetup
1. pip install notion-client
2. Set env vars: NOTION_API_KEY and NOTION_PARENT_PAGE_ID
3. Authorize integration on Notion page (··· > Connect to)
Usage
When the user sends a message matching a trigger pattern, execute the corresponding script:
python scripts/record.py record --type {type} "{content}"
python scripts/record.py heading --level {1|2|3} "{text}"
python scripts/record.py divider
python scripts/record.py list --kind {bullet|number} "{items}"
python scripts/record.py toggle "{json}"
python scripts/record.py image [--caption "text"] "{file_path_or_url}"
python scripts/record.py caption "{content_to_append}"
python scripts/record.py undo
python scripts/check_config.py
python scripts/summary.py {monthly|quote}
Trigger Rules
Content types (prefix → type):
日记: / 今天: / riji: / d → diary笔记: / 学习: / note: / n → note待办: / todo: / t → tododone: / 完成: / √ → done想法: / 灵感: / idea: / flash: / 闪念: / i → idea问题: / 疑问: / q: → question摘抄: / quote: / qu: / z → quote链接: / link: / url: / l → link图片: / photo: / img: / p → imagecaption: / 说明: / 补: → caption (append to last entry)Formats:
* text → H1 heading** text → H2 heading*** text → H3 heading> text → quote block--- → divider- text → bulleted list1. text / 2. text etc → numbered listtoggle: title + subsequent - / -- / --- lines → toggle blockCommands:
月报 / monthly → extract current month records for summary摘抄 / 随机摘抄 → random historical entry搜: xxx / search: xxx → search records by keyword撤回 / undo → delete last batch of blocks (within 5 min window)配置检查 / check config → verify configSmart detection (no prefix, AI infers):
[ ] or 【 】 → todoCaption — two distinct uses:
caption: / 说明: / 补: has two different behaviors depending on context:
1. Caption Append (standalone — no image/link in message)
When the user sends caption: as the primary prefix of a message with no images or links, it appends the content to the last callout on the Notion page:
caption: 补充一个角度 → appends "↳ 补充一个角度" as a child paragraph inside the last callout说明: 这个想法还有一个延伸 → same behavior补: 对了还有一点 → same behaviorImplementation: Write content to .pending_content.txt, then run python scripts/record.py caption.
Visual: The appended paragraph is prefixed with ↳ to distinguish it from the original content.
2. Caption Separator (with image/link in message)
When the message contains images or links, caption: acts as a separator between diary content and image/link caption:
OPPO园区很好 caption: 园区环境 + 3 images → last image gets caption "园区环境", diary "OPPO园区很好" synced separatelycaption:, all text is diary/idea content, no caption on imagesIMPORTANT: The AI must check whether the message contains images or links to determine which caption behavior to use.
Metadata
Scan the LAST line for metadata:
#关键词 → tag/p:项目名 → projectBatch & Undo
Output Protocol
Scripts emit standardized output prefixes:
OK|message → success, relay success message to userERROR|CONFIG → guide user to set up Notion integrationERROR|AUTH → invalid API key or page not authorizedERROR|RATE_LIMIT → tell user to waitERROR|NETWORK → tell user to retry laterAlways run check_config.py first on first use. Never modify or delete existing Notion blocks.
Image Upload
C:\Users\photos\img.jpg) and HTTP URLs (e.g., https://example.com/photo.png)--caption flag to add caption text to the imageImage + Text Sync Rules
When user sends both image and text in one message:
1. Parse text: split by caption: / 说明: keyword (if present) — this is the Caption Separator mode
- Before caption: → diary/idea/note content (synced as callout)
- After caption: → image caption (added to last image via --caption)
2. Upload images: first N-1 images without caption, last image with --caption
3. Sync text: write diary/idea content to .pending_content.txt, then record.py record --type {type}
Examples:
OPPO园区很好 caption: 园区环境 + 3 images → last image gets caption "园区环境", diary "OPPO园区很好" synced separately这张图有意思 + 1 image → no caption keyword, so no caption on image, "这张图有意思" synced as ideaIMPORTANT:
record.py image, text via record.py recordrecord.py image. Do NOT transcribe/OCR the image content into a calloutLink + Caption
Same caption: pattern works for links:
链接: https://example.com caption: 好文章 → bookmark with caption "好文章"caption:, just a plain bookmark card (Notion auto-fetches title)Long Content Auto-Split
.pending_content.txt at once — do NOT manually split into multiple callsBest Practices for AI Callers
.pending_content.txt (write file → run script). Never pass content via command-line args (PowerShell $ expansion issues)..pending_image.jpg, the script auto-detects and cleans up.caption: / 说明: / 补: → caption (append to last entry)
- Contains "日记"/"今天" → diary
- Contains URL → link
- Image only → image (use record.py image)
- Default → idea
record.py undo — respects 5-min batch window, deletes all blocks from last batch.💡 Examples
When the user sends a message matching a trigger pattern, execute the corresponding script:
python scripts/record.py record --type {type} "{content}"
python scripts/record.py heading --level {1|2|3} "{text}"
python scripts/record.py divider
python scripts/record.py list --kind {bullet|number} "{items}"
python scripts/record.py toggle "{json}"
python scripts/record.py image [--caption "text"] "{file_path_or_url}"
python scripts/record.py caption "{content_to_append}"
python scripts/record.py undo
python scripts/check_config.py
python scripts/summary.py {monthly|quote}
⚙️ Configuration
1. pip install notion-client
2. Set env vars: NOTION_API_KEY and NOTION_PARENT_PAGE_ID
3. Authorize integration on Notion page (··· > Connect to)