คลังข้อความ (Rich/Template/Quick Reply)
ภาพรวม
Domain นี้มี 3 ตาราง คือ rich_message (เนื้อหาข้อความที่ใช้ส่งในแคมเปญและการตอบกลับอัตโนมัติ
รองรับทั้ง text, image, tappable image, flex message), template_message (ข้อความสำเร็จรูปที่สร้าง
จาก showcase template) และ quick_reply (ชุดปุ่มตอบกลับด่วนที่แนบไปกับข้อความได้)
ตาราง rich_message
| Column | Type | Nullable | Default | คำอธิบาย |
|---|---|---|---|---|
id | SERIAL (INTEGER) | NO | nextval(...) | รหัสอ้างอิงหลักของข้อความ |
title | TEXT | NO | - | ชื่อข้อความสำหรับใช้อ้างอิงในระบบ |
content | JSONB | NO | - | เนื้อหาข้อความในรูปแบบ JSON ตามชนิดที่ระบุใน type |
line_oa_id | INTEGER | NO | - | รหัส LINE OA เจ้าของข้อความ (FK ไป line_oa.id) |
type | "RichMessageType" | NO | - | ชนิดข้อความ: text, image, tappable_image, flex_message |
quick_reply_id | UUID | YES | - | รหัสชุด quick reply ที่แนบกับข้อความนี้ (อ้างถึง quick_reply.id) |
status | "CommonStatus" | NO | - | สถานะของข้อความ (active, inactive, draft, ...) |
created_date | TIMESTAMPTZ(3) | NO | now() | วันเวลาที่สร้างรายการ |
created_by | INTEGER | NO | 0 | รหัสผู้ใช้ที่สร้างรายการ |
updated_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่แก้ไขล่าสุด (อัปเดตอัตโนมัติ) |
updated_by | INTEGER | YES | 0 | รหัสผู้ใช้ที่แก้ไขล่าสุด |
deleted_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่ลบแบบ soft delete |
ตาราง template_message
| Column | Type | Nullable | Default | คำอธิบาย |
|---|---|---|---|---|
id | UUID | NO | gen_random_uuid() | รหัสอ้างอิงหลักของ template message |
organization_id | INTEGER | NO | 0 | รหัสองค์กรเจ้าของข้อมูล |
line_oa_id | INTEGER | NO | - | รหัส LINE OA เจ้าของ template (FK ไป line_oa.id) |
title | TEXT | NO | - | ชื่อ template message |
template_message_showcase_id | INTEGER | NO | - | รหัส showcase template ต้นแบบที่ใช้สร้างรายการนี้ |
line_template_message | JSONB | YES | - | โครงสร้างข้อความรูปแบบ LINE Messaging API ที่พร้อมส่ง |
form_template_message | JSONB | YES | - | ข้อมูลฟอร์มที่ผู้ใช้กรอกในหน้าจอแก้ไข ใช้ประกอบขึ้นเป็น line_template_message |
status | "CommonStatus" | NO | active | สถานะของ template |
created_date | TIMESTAMPTZ(3) | NO | now() | วันเวลาที่สร้างรายการ |
created_by | INTEGER | NO | 0 | รหัสผู้ใช้ที่สร้างรายการ |
updated_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่แก้ไขล่าสุด (อัปเดตอัตโนมัติ) |
updated_by | INTEGER | YES | 0 | รหัสผู้ใช้ที่แก้ไขล่าสุด |
deleted_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่ลบแบบ soft delete |
ตาราง quick_reply
| Column | Type | Nullable | Default | คำอธิบาย |
|---|---|---|---|---|
id | UUID | NO | gen_random_uuid() | รหัสอ้างอิงหลักของชุด quick reply |
line_oa_id | BIGINT | NO | - | รหัส LINE OA เจ้าของชุด quick reply |
organization_id | BIGINT | NO | - | รหัสองค์กรเจ้าของข้อมูล |
name | TEXT | NO | - | ชื่อชุด quick reply |
items | JSONB | NO | [] | รายการปุ่ม quick reply (label และ action ของแต่ละปุ่ม) |
status | TEXT | NO | 'active' | สถานะการใช้งานของชุด quick reply |
created_date | TIMESTAMPTZ(3) | NO | now() | วันเวลาที่สร้างรายการ |
created_by | BIGINT | NO | 0 | รหัสผู้ใช้ที่สร้างรายการ |
updated_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่แก้ไขล่าสุด (อัปเดตอัตโนมัติ) |
updated_by | BIGINT | YES | - | รหัสผู้ใช้ที่แก้ไขล่าสุด |
deleted_date | TIMESTAMPTZ(3) | YES | - | วันเวลาที่ลบแบบ soft delete |
หมายเหตุ
rich_message.line_oa_idและtemplate_message.line_oa_idเป็น FK ไปยังline_oa.idrich_messageถูกอ้างอิงโดยcampaign.rich_message_idและauto_response.rich_message_idrich_message.quick_reply_idเก็บเป็น UUID และมี index รองรับ แต่ไม่ได้ประกาศเป็น FK constraint ใน schema (ชี้ไปที่quick_reply.idเชิงตรรกะ)- Index สำคัญ:
rich_messageมี index บนline_oa_idและquick_reply_id;template_messageมี index บน (line_oa_id,template_message_showcase_id,status) และcreated_date;quick_replyมี index บน (line_oa_id,status) และcreated_date quick_replyใช้BIGINTสำหรับคอลัมน์ id อ้างอิง (line_oa_id,organization_id,created_by,updated_by) ต่างจากอีก 2 ตารางที่ใช้INTEGER