บันทึกอย่างละเอียด — ระบบ monitor + วิเคราะห์ Google Ads อัตโนมัติด้วย AI พร้อมระบบ feedback loop ปิด
Production: https://joey-ads.duckdns.org/ · LINE OA: @630pzmtx · VPS: 72.62.79.218
ปัญหาเดิม: ดู Google Ads ต้องเปิด dashboard รายวัน, export Excel, ตีความหมายเอง, ตัดสินใจจากความรู้สึก — ช้า, ขาดทุน, พลาดโอกาส
เป้าหมาย: AI ดูข้อมูลที่เชื่อถือได้ → เสนอ action ที่ตรวจสอบได้ → user decide → วัดผล → เรียนจากความผิดพลาดของตัวเอง
┌──────────────────────────────────────────────────────────────┐
│ Google Ads API v30 (GAQL) │
└────────┬────────────────────────────────────────────────────────┘
│ ads_client.py (06:00 snapshot, real-time fetches)
▼
┌──────────────────────────────────────────────────────────────┐
│ PostgreSQL 16 (snapshots, actions, outcomes, experiments, context) │
│ Qdrant v1.13 (vector KB — RAG retrieval) │
└────────┬────────────────────────────────────────────────────────┘
│
├─▶ analyzer.py — Tier 1: daily account report
├─▶ campaign_analyzer.py — Tier 1.5: per-campaign analysis
├─▶ strategic_advisor.py — Tier 2: weekly strategic review (RAG)
├─▶ drift_detector.py — anomaly detection
├─▶ outcome_measurer.py — T+7/14/30 measurement
├─▶ experiments.py — Bayesian A/B engine
└─▶ bayesian_priors.py — device×network posteriors
│
▼
┌──────────────────────────────────────────────────────────────┐
│ Output channels │
│ • LINE OA broadcast (notifier.py) — รายวัน/สัปดาห์ │
│ • FastAPI dashboard — Accept/Reject/Implement │
│ • PostgreSQL — long-term memory │
└──────────────────────────────────────────────────────────────┘
metric_snapshots (PK: date × entity × device × network)drift_detector เทียบกับ baseline (rolling 7d, 14d, 30d)actions table (UUID, grade, expected_impact, status=pending)actions.statusoutcomes table → เปรียบ expected vs actual| Tier | ความถี่ | Model | ขอบเขต | ต้นทุน |
|---|---|---|---|---|
| 1 | รายวัน 08:00 | Sonnet 4.5 | account-level summary | ต่ำ |
| 1.5 | รายสัปดาห์ จ. 09:00 | Sonnet 4.5 | per-campaign analysis | ปานกลาง |
| 2 | Strategic จ. 10:00 | Sonnet 4.5 + RAG | ข้ามสัปดาห์, เชิงลึก | สูง |
| Pulse | 18:00 | — (no LLM) | snapshot + alerts | ถูกมาก |