Files
lcbp3/specs/88-logs/session-2026-05-23-n8n-refactor.md
T
admin 52b96d01de
CI / CD Pipeline / build (push) Successful in 5m5s
CI / CD Pipeline / deploy (push) Successful in 3m48s
690608:0012 ADR-035-135 #08
2026-06-08 00:12:31 +07:00

3.1 KiB

Session 2 — 2026-05-23 (N8N Workflow Refactor)

Decisions ที่ Lock แล้ว (จาก QuizMe Session)

# Decision
S1 n8n = Migration only — New Correspondence ใช้ Backend pipeline (BullMQ)
S2 New Correspondence → BullMQ ai-realtime (ไม่ผ่าน n8n)
S3 n8n call POST /api/ai/jobs (Backend) แทน Ollama direct (ADR-023A)
PA Excel metadata (docNumber, title, sender, etc.) ส่งไปพร้อม AI job เป็น context
PB-Tags Tag suggestion ทาง C — แนะนำ existing + สร้าง tag ใหม่ได้ถ้าไม่มี (isNew flag)
PB-UX Editable form pre-filled ด้วย AI suggestions — user approve/edit ก่อน submit

Endpoint ที่ Verified แล้ว

  • POST /api/ai/jobs (type: migrate-document) — พร้อมใช้งานแล้ว (verified 2026-05-23)
  • GET /api/ai/jobs/:jobId — polling endpoint พร้อม
  • POST /api/storage/upload — two-phase upload พร้อม

ไฟล์ที่สร้าง/แก้ไข

ไฟล์ การเปลี่ยนแปลง
specs/03-Data-and-Storage/CONTEXT-N8N-Refactor.md สร้างใหม่ — context doc สำหรับ implement
specs/03-Data-and-Storage/n8n.workflow.v2.json สร้างใหม่ — ADR-023A compliant workflow
specs/03-Data-and-Storage/03-05-n8n-migration-setup-guide.md อัพเดต v1.9.0 — ลบ Ollama direct, เพิ่มขั้นตอน update token
specs/03-Data-and-Storage/03-06-migration-business-scope.md อัพเดต — Gate #1 blocker → Verified 2026-05-23

สาระสำคัญของ n8n.workflow.v2.json

Nodes ที่ลบ (ADR-023A violations): Ollama AI Analysis, Build AI Prompt, Extract PDF Text (Tika), Check/Update Fallback State, Import to Backend, Upsert Tags, Link Tags

Nodes ใหม่: Validate TokenUpload PDF to BackendBuild AI Job PayloadSubmit AI JobPoll AI Job Status

Flow สรุป:

Form Trigger → Set Config → Health/Token Check → Fetch Master Data
→ File Mount Check → Read Excel → Read Checkpoint
→ [Per Record: File Validate → Upload PDF → Submit AI Job → Poll → Parse/Route]
    → Auto/Flagged → migration_review_queue
    → Rejected → CSV Log
    → Error → CSV + DB Log
→ Save Checkpoint → Delay → Loop