Repository นี้คือระบบ ChatGPT Apps SDK + MCP + Notion สำหรับรับข้อความจากแชท, classify งานอัตโนมัติ, เก็บเป็น structured records, และ sync ลง Notion แบบ controlled write.
This repository provides a ChatGPT Apps SDK + MCP + Notion runtime for autonomous conversation capture, record classification, and controlled-write Notion synchronization.
| TH | EN |
|---|---|
ค้นหาและเปิด knowledge docs ผ่าน widget (search, fetch, render_search_widget) |
Search and fetch knowledge docs via widget (search, fetch, render_search_widget) |
จับข้อความจากแชทเป็น task, todo, research, knowledge, incident, inbox |
Capture chat messages into task, todo, research, knowledge, incident, inbox |
| จัดการวงจรงานผ่าน MCP และ HTTP endpoints | Manage record lifecycle via MCP tools and HTTP endpoints |
| sync ลง Notion แบบ downstream โดย local store ยังเป็น source of truth | Sync to Notion as downstream while local store remains source of truth |
| เลือกหน้าเอกสาร Notion template ได้ 3 โหมดจาก Git/CLI | Choose among 3 Git/CLI Notion template modes |
server/src/index.ts: MCP server + HTTP automation endpointsserver/src/automation-engine.ts: classification, dedupe, status lifecycleserver/src/notion-sync.ts: map fields และ sync ลง Notiondata/automation-store.json: local persistence (authoritative store)web/src/component.tsx: React widget UI
server/src/index.ts: MCP server + HTTP automation endpointsserver/src/automation-engine.ts: classification, dedupe, status lifecycleserver/src/notion-sync.ts: field mapping and downstream Notion syncdata/automation-store.json: authoritative local persistenceweb/src/component.tsx: React widget UI
nvm use
npm install
npm run build
npm startNode version is pinned in .nvmrc (22).
npm run dev
npm run dev:tunnel
npm run check
npm test
npm run build
npm run inspectcapture_conversationlist_automation_recordsupdate_automation_record_statusrun_follow_up_cycle
GET /automation/stateGET /automation/recordsPOST /automation/capturePOST /automation/records/statusPOST /automation/followups/run
รองรับ template โหมด:
en-only(อังกฤษอย่างเดียว)th-en-split(ไทยและอังกฤษแยกคนละหน้า, default production)bilingual(หน้าเดียวมีทั้ง TH และ EN โดย TH ก่อน)
Supported template modes:
en-onlyth-en-split(separate TH and EN pages, default production mode)bilingual(single page with TH-first bilingual content)
Commands:
npm run notion:templates:list
npm run notion:templates:validate
npm run notion:templates:apply -- --mode=en-only
npm run notion:templates:apply -- --mode=th-en-split
npm run notion:templates:apply -- --mode=bilingualapply runs in dry-run by default. Use --write to generate rendered output under docs/notion-templates/build/<mode>/.
Source of truth:
- docs/notion-templates/manifest.json
- docs/notion-templates/README.md
- scripts/notion-template-mode.mjs
Routing:
task,todo->Work Itemsresearch->Research Libraryknowledge->Knowledge Hubincident->Incident Registerinbox->Conversation Inbox
Key mapped fields now include:
Source Conversation IDMessage IDSource URL/Source Record URLConfidencePolicy ModeSource Channel
Still supported for compatibility with older workspace structure.
Quick enable:
export NOTION_SYNC_ENABLED=true
export NOTION_SYNC_PROFILE=personal-kb-v2
export NOTION_API_TOKEN=your_notion_integration_tokenSee full list in .env.example. Most important:
NOTION_SYNC_ENABLEDNOTION_SYNC_PROFILENOTION_API_TOKENNOTION_<TYPE>_DATA_SOURCE_IDorNOTION_<TYPE>_DATABASE_IDNOTION_<TYPE>_*_PROPERTYoverridesOPENAI_API_KEYorANTHROPIC_API_KEY(optional, for model-based classification)
Security-related variables:
ALLOWED_DOC_HOSTSALLOWED_MCP_ORIGINSAUTH_BEARER_TOKENENABLE_OAUTH_CHALLENGETENANT_ID_HEADER,REQUIRE_TENANT_IDRATE_LIMIT_WINDOW_MS,RATE_LIMIT_MAX_REQUESTS
npm test
npm run check
npm run build
npm run notion:templates:validate -- --allManual runtime checks:
- Start server:
npm start - Check root health:
http://localhost:8787/ - Check automation state:
http://localhost:8787/automation/state - Run capture smoke test and verify
syncobject in response
- Repo นี้ถูก sanitize แล้ว และใช้ policy “no personal identifiers in Git”
- สำหรับเครื่องที่เคย clone ก่อน history rewrite ให้ sync ใหม่ด้วย
reset --hardหรือ clone ใหม่ - ก่อน push ให้สแกนหา PII/IDs ด้วย
rgตามคู่มือ
- This repo has been sanitized and follows a no-personal-identifiers-in-Git policy.
- Existing clones from before the history rewrite must hard-reset or re-clone.
- Run the pre-push PII scan before every push.
รายละเอียดดูที่:
- docs/notion-personal-kb-v2-setup.md
- docs/notion-live-sync-setup.md
- docs/personal-kb-v2-migration-batch-001.md
- docs/notion-templates/README.md
- docs/repository-privacy-guidelines.md
- Local store เป็นตัวจริง แม้ Notion sync จะล้มเหลว
- sync errors จะรายงานผ่าน
syncobject โดยไม่ rollback capture - การ migrate จาก workspace เก่าใช้แนว curated batches ไม่ใช้ bulk import
- Local store remains authoritative even when Notion sync fails.
- Sync failures are surfaced via
syncresponse object and do not roll back capture. - Legacy migration follows curated batches (no bulk import).