Platform
Notification
Overview

Notification

Base URL: https://notification-api.pcampus.co

Overview

Notification คือ centralized notification hub สำหรับทุก service ใน Pcampus ecosystem แทนที่แต่ละ service จะส่ง notification เอง ทุกอย่างผ่าน Notification service เดียว ทำให้จัดการ template, delivery, และ analytics ได้จากที่เดียว

รองรับช่องทาง: Email, Push notification, SMS, LINE

Who uses this

Personaใช้ทำอะไร
Developer (internal service)เรียก API ส่ง notification จาก Cockpit / Content OS / Billing
Developer (ลูกค้า)ส่ง notification ถึง user ของตัวเองผ่าน API
Adminจัดการ templates, ดู delivery analytics
End userรับ notification, จัดการ notification preferences

Key features

  • Multi-channel delivery — Email, Push, SMS, LINE จาก API เดียว
  • Template management — สร้าง template พร้อม variable substitution ({{user.name}}, {{booking.date}})
  • Notification preferences — User เลือกได้ว่าอยากรับ notification ช่องทางไหน
  • Delivery tracking — ติดตาม sent / delivered / opened / failed ต่อ notification
  • Retry & fallback — ถ้าส่ง SMS ไม่ได้ fallback ไป Email อัตโนมัติ
  • Rate limiting — ป้องกันส่ง notification มากเกินไปถึง user คนเดียว

User stories

Internal service (Billing):

"เมื่อ payment สำเร็จ ต้องการแจ้ง org admin ทันทีผ่าน Email"

POST /notifications/send ระบุ channel: email, templateId: payment-success, userId → ส่งทันที

Developer (ลูกค้า):

"ผมต้องการส่ง push notification ถึง user ที่ app ของผมเมื่อมี order ใหม่"

→ Register application → สร้าง template → เรียก API ส่ง push พร้อม payload

End user:

"ผมอยากรับแจ้งเตือนผ่าน LINE แทน SMS"

→ Console → Notification Settings → เลือก LINE → เชื่อม LINE account

How it works

Data model

Integration

  • PIP — ดึง user preferences และ contact info (email, phone, LINE ID)
  • Mail — ใช้ Mail service สำหรับ email delivery (ไม่ส่ง email ตรงเอง)
  • Other services — รับ event แล้วส่ง notification ตาม template

API overview

MethodEndpointDescription
POST/notifications/sendSend notification to user
POST/notifications/broadcastSend to multiple users
GET/notificationsList notification history
GET/notifications/:idGet delivery status
GET/templatesList templates
POST/templatesCreate template
PATCH/templates/:idUpdate template
DELETE/templates/:idDelete template
GET/preferences/:userIdGet user notification preferences
PATCH/preferences/:userIdUpdate preferences

Send notification payload

{
  "userId": "usr_xxxx",
  "templateId": "tmpl_xxxx",
  "channel": "email",
  "data": {
    "user": { "name": "Somchai" },
    "booking": { "id": "BK-001", "date": "2026-08-01" }
  }
}

LINE Flex Message Templates

LINE Flex Message คือ rich message format ของ LINE ที่กำหนด layout ด้วย JSON — รองรับ card, carousel, image hero, button, และ separator ได้อย่างอิสระ

Notification รองรับ template type flex_message เพิ่มเติมจาก text ธรรมดา ใส่ variable slots ด้วย syntax {{variableName}} เหมือนกัน — ระบบจะ substitute ค่าลงใน JSON ก่อนส่งออก LINE

Template types

Typeรูปแบบใช้กับ
textข้อความธรรมดาแจ้งเตือนทั่วไป, OTP
flex_messageJSON Flex layoutProduct card, order summary, appointment reminder
image_mapรูปพร้อม tap zonesBanner โปรโมชั่น
carouselFlex แบบ swipeหลาย product, หลาย branch

ตัวอย่าง Flex Message template — Order Card

{
  "type": "flex",
  "altText": "ยืนยันคำสั่งซื้อ {{orderId}}",
  "contents": {
    "type": "bubble",
    "hero": {
      "type": "image",
      "url": "{{productImageUrl}}",
      "size": "full",
      "aspectRatio": "20:13",
      "aspectMode": "cover"
    },
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "สวัสดีครับ {{customerName}}",
          "weight": "bold",
          "size": "xl"
        },
        {
          "type": "text",
          "text": "คำสั่งซื้อ #{{orderId}} ได้รับแล้ว",
          "color": "#aaaaaa",
          "size": "sm"
        },
        {
          "type": "separator",
          "margin": "md"
        },
        {
          "type": "box",
          "layout": "vertical",
          "margin": "md",
          "contents": [
            {
              "type": "box",
              "layout": "horizontal",
              "contents": [
                { "type": "text", "text": "{{productName}}", "size": "sm", "flex": 3 },
                { "type": "text", "text": "{{total}}", "size": "sm", "align": "end" }
              ]
            }
          ]
        }
      ]
    },
    "footer": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "button",
          "style": "primary",
          "action": {
            "type": "uri",
            "label": "ดูรายละเอียด",
            "uri": "{{orderDetailUrl}}"
          }
        }
      ]
    }
  }
}

Variable slots ในตัวอย่างนี้: customerName, orderId, productImageUrl, productName, total, orderDetailUrl

Flex Message Builder (Console)

ใน Pcampus Console → Notification → Templates → New Template → เลือก Flex Message:

ขั้นตอน:

  1. เลือก layout เริ่มต้น — Bubble, Carousel, Image Hero, Receipt
  2. แก้ไข block — คลิก block เพื่อแก้ text, สี, ขนาด, URL ปุ่ม
  3. ใส่ variable — พิมพ์ {{ เพื่อ autocomplete variable ที่ระบบ suggest จาก Customer Story
  4. Preview — ดู preview บน LINE emulator ทั้ง Android / iOS
  5. Save และ Test send — ส่ง test ไป LINE account จริงก่อน publish

ตัว builder ใน Console ใช้ LINE Flex Message Simulator เดียวกันกับ LINE Official — JSON ที่ได้สามารถ copy ไปทดสอบใน Flex Message Simulator (opens in a new tab) ได้โดยตรง

Carousel template

Carousel คือ collection ของ bubble ที่ swipe ได้ เหมาะกับ multi-product, multi-branch:

{
  "type": "flex",
  "altText": "สินค้าแนะนำสำหรับคุณ {{customerName}}",
  "contents": {
    "type": "carousel",
    "contents": [
      "{{#each recommendations}}",
      {
        "type": "bubble",
        "body": {
          "type": "box",
          "layout": "vertical",
          "contents": [
            { "type": "text", "text": "{{this.name}}", "weight": "bold" },
            { "type": "text", "text": "{{this.price}}", "color": "#1DB446" }
          ]
        }
      },
      "{{/each}}"
    ]
  }
}

{{#each recommendations}} / {{/each}} คือ loop syntax สำหรับ array variables — รองรับใน Flex Message template เท่านั้น


Broadcast Scheduler

Scheduler ใน Notification จัดการ scheduled broadcasts ของทุกช่องทาง (LINE, Push, SMS) — เห็นและสร้างได้จาก calendar view เดียว

Console → Notification → Scheduler

Calendar view

แสดง scheduled broadcasts ทุกช่องทางในปฏิทินเดียวกัน กรองตาม channel / segment / status ได้:

┌─────────────────────────────────────────────────────────────┐
│  📅  Notification Scheduler — กรกฎาคม 2026                 │
│  [+ New Broadcast]   [All Channels ▼]   [List] [Calendar]  │
├──────────┬──────────┬──────────┬──────────┬────────────────┤
│  จ 14    │  อ 15    │  พ 16    │  พฤ 17   │  ศ 18           │
├──────────┼──────────┼──────────┼──────────┼────────────────┤
│          │ 09:00    │ 14:00    │ 10:00    │                │
│          │ 📱 LINE  │ 🔔 Push  │ 📱 LINE  │                │
│          │ Winback  │ Flash    │ Loyalty  │                │
│          │ 3,241 คน │ 8,002 คน │ 1,532 คน │                │
│          │          │ Sale     │ Tier Up  │                │
└──────────┴──────────┴──────────┴──────────┴────────────────┘

สร้าง Scheduled Broadcast

  1. + New Broadcast → เลือก channel: LINE | Push | SMS
  2. เลือก template — text หรือ Flex Message
  3. กำหนด recipients — segment, subscriber list, หรือ customer ID list
  4. ตั้งเวลา — วันที่ + เวลา หรือ recurrence (daily / weekly / monthly)
  5. ตั้งค่า rate limit — กี่ message ต่อนาที ป้องกัน burst
  6. Confirm → ปรากฎบน calendar ทันที สามารถ edit / cancel ได้จนถึง 5 นาทีก่อนส่ง

Recurrence patterns

PatternCronตัวอย่างใช้งาน
ทุกวัน 08:000 8 * * *Daily order reminder
ทุกวันจันทร์0 9 * * 1Weekly loyalty summary
วันที่ 1 ทุกเดือน0 10 1 * *Monthly points digest
ทุกวันศุกร์บ่าย0 14 * * 5Flash sale LINE

Delivery window

ตั้ง delivery window เพื่อไม่รบกวนลูกค้านอกเวลา:

{
  "deliveryWindow": {
    "start": "08:00",
    "end": "21:00",
    "timezone": "Asia/Bangkok",
    "skipWeekends": false
  }
}

ถ้า broadcast trigger นอก window ระบบจะ hold และส่งเมื่อเริ่ม window ถัดไป

ดู Notification API → Scheduler สำหรับ REST endpoints

Notification

Base URL: https://notification-api.pcampus.co

Overview

Notification is a centralized notification hub for every service in the Pcampus ecosystem. Instead of each service sending its own notifications, everything flows through a single Notification service — making it easy to manage templates, delivery, and analytics from one place.

Supported channels: Email, Push notifications, SMS, LINE

Who uses this

PersonaWhat They Do
Developer (internal service)Call the API to send notifications from Cockpit / Content OS / Billing
Developer (customer)Send notifications to their own users via the API
AdminManage templates, view delivery analytics
End userReceive notifications, manage notification preferences

Key features

  • Multi-channel delivery — Email, Push, SMS, LINE from a single API
  • Template management — Create templates with variable substitution ({{user.name}}, {{booking.date}})
  • Notification preferences — Users can choose which channels they want to receive notifications on
  • Delivery tracking — Track sent / delivered / opened / failed per notification
  • Retry & fallback — If SMS fails, automatically falls back to Email
  • Rate limiting — Prevent sending too many notifications to a single user

User stories

Internal service (Billing):

"When a payment succeeds, we need to notify the org admin immediately via Email"

POST /notifications/send — specify channel: email, templateId: payment-success, userId → send immediately

Developer (customer):

"I want to send a push notification to users in my app when a new order arrives"

→ Register application → create template → call the API to send push with payload

End user:

"I'd like to receive notifications via LINE instead of SMS"

→ Console → Notification Settings → select LINE → connect LINE account

How it works

Data model

Integration

  • PIP — Fetches user preferences and contact info (email, phone, LINE ID)
  • Mail — Uses the Mail service for email delivery (does not send email directly)
  • Other services — Receive events and send notifications according to templates

API overview

MethodEndpointDescription
POST/notifications/sendSend notification to user
POST/notifications/broadcastSend to multiple users
GET/notificationsList notification history
GET/notifications/:idGet delivery status
GET/templatesList templates
POST/templatesCreate template
PATCH/templates/:idUpdate template
DELETE/templates/:idDelete template
GET/preferences/:userIdGet user notification preferences
PATCH/preferences/:userIdUpdate preferences

Send notification payload

{
  "userId": "usr_xxxx",
  "templateId": "tmpl_xxxx",
  "channel": "email",
  "data": {
    "user": { "name": "Somchai" },
    "booking": { "id": "BK-001", "date": "2026-08-01" }
  }
}

LINE Flex Message Templates

LINE Flex Message is LINE's rich message format with JSON-defined layouts — supports card, carousel, image hero, button, and separator elements freely.

Notification supports the flex_message template type in addition to plain text. Variable slots use the same {{variableName}} syntax — the system substitutes values into the JSON before sending to LINE.

Template types

TypeFormatUse case
textPlain textGeneral notifications, OTP
flex_messageJSON Flex layoutProduct card, order summary, appointment reminder
image_mapImage with tap zonesPromotional banners
carouselSwipeable FlexMultiple products, multiple branches

Flex Message Template Example — Order Card

{
  "type": "flex",
  "altText": "ยืนยันคำสั่งซื้อ {{orderId}}",
  "contents": {
    "type": "bubble",
    "hero": {
      "type": "image",
      "url": "{{productImageUrl}}",
      "size": "full",
      "aspectRatio": "20:13",
      "aspectMode": "cover"
    },
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "สวัสดีครับ {{customerName}}",
          "weight": "bold",
          "size": "xl"
        },
        {
          "type": "text",
          "text": "คำสั่งซื้อ #{{orderId}} ได้รับแล้ว",
          "color": "#aaaaaa",
          "size": "sm"
        },
        {
          "type": "separator",
          "margin": "md"
        },
        {
          "type": "box",
          "layout": "vertical",
          "margin": "md",
          "contents": [
            {
              "type": "box",
              "layout": "horizontal",
              "contents": [
                { "type": "text", "text": "{{productName}}", "size": "sm", "flex": 3 },
                { "type": "text", "text": "{{total}}", "size": "sm", "align": "end" }
              ]
            }
          ]
        }
      ]
    },
    "footer": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "button",
          "style": "primary",
          "action": {
            "type": "uri",
            "label": "ดูรายละเอียด",
            "uri": "{{orderDetailUrl}}"
          }
        }
      ]
    }
  }
}

Variable slots in this example: customerName, orderId, productImageUrl, productName, total, orderDetailUrl

Flex Message Builder (Console)

In Pcampus Console → Notification → Templates → New Template → select Flex Message:

Steps:

  1. Choose a starting layout — Bubble, Carousel, Image Hero, Receipt
  2. Edit blocks — click a block to change text, color, size, button URL
  3. Insert variables — type {{ to autocomplete variables suggested from the Customer Story
  4. Preview — view on the LINE emulator for both Android / iOS
  5. Save and Test send — send a test to a real LINE account before publishing

The builder in Console uses the same LINE Flex Message Simulator as LINE Official — the generated JSON can be copied directly into the Flex Message Simulator (opens in a new tab) for testing.

Carousel template

Carousel is a collection of swipeable bubbles, ideal for multi-product, multi-branch use cases:

{
  "type": "flex",
  "altText": "สินค้าแนะนำสำหรับคุณ {{customerName}}",
  "contents": {
    "type": "carousel",
    "contents": [
      "{{#each recommendations}}",
      {
        "type": "bubble",
        "body": {
          "type": "box",
          "layout": "vertical",
          "contents": [
            { "type": "text", "text": "{{this.name}}", "weight": "bold" },
            { "type": "text", "text": "{{this.price}}", "color": "#1DB446" }
          ]
        }
      },
      "{{/each}}"
    ]
  }
}

{{#each recommendations}} / {{/each}} is the loop syntax for array variables — supported in Flex Message templates only


Broadcast Scheduler

The Notification Scheduler manages scheduled broadcasts across all channels (LINE, Push, SMS) — viewable and creatable from a single calendar view.

Console → Notification → Scheduler

Calendar view

Shows all scheduled broadcasts from every channel in a single calendar, filterable by channel / segment / status:

┌─────────────────────────────────────────────────────────────┐
│  📅  Notification Scheduler — กรกฎาคม 2026                 │
│  [+ New Broadcast]   [All Channels ▼]   [List] [Calendar]  │
├──────────┬──────────┬──────────┬──────────┬────────────────┤
│  จ 14    │  อ 15    │  พ 16    │  พฤ 17   │  ศ 18           │
├──────────┼──────────┼──────────┼──────────┼────────────────┤
│          │ 09:00    │ 14:00    │ 10:00    │                │
│          │ 📱 LINE  │ 🔔 Push  │ 📱 LINE  │                │
│          │ Winback  │ Flash    │ Loyalty  │                │
│          │ 3,241 คน │ 8,002 คน │ 1,532 คน │                │
│          │          │ Sale     │ Tier Up  │                │
└──────────┴──────────┴──────────┴──────────┴────────────────┘

Create a Scheduled Broadcast

  1. + New Broadcast → select channel: LINE | Push | SMS
  2. Choose a template — text or Flex Message
  3. Define recipients — segment, subscriber list, or customer ID list
  4. Set schedule — date + time, or recurrence (daily / weekly / monthly)
  5. Set rate limit — messages per minute, to prevent burst traffic
  6. Confirm → appears on the calendar immediately; editable / cancellable up to 5 minutes before send

Recurrence patterns

PatternCronExample use
Every day 08:000 8 * * *Daily order reminder
Every Monday0 9 * * 1Weekly loyalty summary
1st of every month0 10 1 * *Monthly points digest
Every Friday afternoon0 14 * * 5Flash sale LINE

Delivery window

Set a delivery window to avoid disturbing customers outside business hours:

{
  "deliveryWindow": {
    "start": "08:00",
    "end": "21:00",
    "timezone": "Asia/Bangkok",
    "skipWeekends": false
  }
}

If a broadcast triggers outside the window, the system will hold it and send when the next window begins.

See Notification API → Scheduler for REST endpoints