CCLINICBOTAI OPERATIONS
SYSTEM CASE STUDY

AI SOLUTION CASE STUDY · 2026

ClinicBotAI clinic operations, from conversation to confirmed care.

แพลตฟอร์ม AI สำหรับคลินิกที่เชื่อมบทสนทนา การนัดหมาย งานหลังบ้าน และระบบอัตโนมัติไว้ใน workflow เดียว

AI SolutionMulti-tenantLLM + RAGAutomationProduction System
01 / 16

BUSINESS → AI → OPERATIONS

02

EXECUTIVE SUMMARY

One system. Five outcomes.

ภาพรวมสำหรับผู้บริหาร: ปัญหา, วิธีแก้, บทบาท AI, automation และผลลัพธ์เชื่อมต่อกันอย่างไร

01

Problem

งานบริการกระจายหลายจุด

การสนทนา นัดหมาย ข้อมูลคนไข้ และงานติดตามผลต้องทำงานต่อเนื่องกัน โดยไม่เพิ่มภาระงานของเจ้าหน้าที่
02

Solution

One operating layer

FastAPI backend เชื่อม LINE, Web Widget และ Dashboard เข้ากับ services ที่แยกความรับผิดชอบชัดเจน
03

AI

Context-aware action

Gemini ใช้ context, Knowledge Base (RAG) และ tool calling เพื่อทั้งตอบคำถามและเรียก workflow ทางธุรกิจ
04

Automation

Always-on operations

ARQ workers จัดการ reminder, scheduled campaign, no-show และ feedback โดยไม่บล็อก API หลัก
05

Impact

Connected clinic journey

เปลี่ยนจาก interaction แยกส่วนเป็น patient journey ที่ต่อเนื่อง พร้อม human handoff เมื่อ AI ไม่ควรทำงานต่อ

LIVE TEST ACCESS

Experience both sides of the system.

เริ่มบทสนทนาใน LINE แล้วเปิด Dashboard เพื่อดู workflow ฝั่งคลินิกด้วยบัญชีสำหรับทดสอบ

ClinicBot LINE Official Account QR code
01 · PATIENT EXPERIENCE

Talk to ClinicBot on LINE

สแกน QR หรือเปิด LINE Official Account เพื่อทดลองสนทนาและ workflow การจอง

Open LINE OA
02 · CLINIC OPERATIONS

Open the live Dashboard

Launch Dashboard
EMAILcloud.care.admin@cloudcareclinic.com
PASSWORDCloudcareadmin@2026

For interview testing only · บัญชีนี้จัดเตรียมไว้สำหรับทดลองระบบ

03

THE PROBLEM

Continuity is the hard part.

โจทย์ไม่ใช่แค่ให้บอทตอบได้ แต่คือการรักษา context และสถานะธุรกิจให้ต่อเนื่องตลอด patient journey

01

CURRENT PROCESS

หลายช่องทางและหลายงาน

ผู้ป่วยสนทนาและจองผ่าน LINE หรือ Web ขณะที่เจ้าหน้าที่จัดการผ่าน Dashboard
02

OPERATIONAL PRESSURE

Context ต้องไม่หลุด

ข้อความ ประวัติคนไข้ สถานะนัดหมาย และ usage limit ต้องสอดคล้องกันในทุก interaction
03

BUSINESS IMPACT

บริการต้อง scale โดยยังควบคุมได้

AI ต้องช่วยลดงานซ้ำ แต่ต้องหยุดตอบเมื่อเจ้าหน้าที่รับช่วง และทุก action สำคัญควรตรวจสอบย้อนหลังได้
04

THE SOLUTION

A connected operating layer.

ทุก layer มี responsibility, contract และ output ชัดเจน—จาก human interaction ไปถึง durable state

01

Channels

LINE OA · Web Widget · Dashboard

รับ interaction จากผู้ป่วยและเจ้าหน้าที่

INPUT
Message · Postback · Staff action
OUTPUT
Webhook · Web API · REST/WebSocket
02

Application

FastAPI · Service layer

ตรวจสิทธิ์, route workflow และรักษา separation of concerns

INPUT
Verified request
OUTPUT
Service operation
03

Intelligence

Google Gemini · RAG · Tool calling

เข้าใจบริบท ค้นความรู้ และตัดสินใจเรียกเครื่องมือ

INPUT
Prompt · Context · Retrieved knowledge
OUTPUT
Response · Function call
04

Operations

Appointment · Conversation · Campaign

เปลี่ยน intent เป็น business action ที่ควบคุมสถานะได้

INPUT
Validated command
OUTPUT
Appointment · Message · State change
05

Data & Jobs

PostgreSQL/pgvector · Redis · ARQ

เก็บข้อมูล/vector, realtime events และกระจายงานเบื้องหลัง

INPUT
Records · Vectors · Jobs
OUTPUT
Persistent state · Events · Scheduled actions
05

AI SOLUTION ARCHITECTURE

From channel to intelligence—and back.

คลิกแต่ละ node เพื่อดู responsibility, input/output และ dependency ตามหลักฐานในเอกสาร

ExperienceApplicationAIDataInfrastructureExternal
PRIMARY RUNTIME PATH

Channels → FastAPI → Services → Gemini/Data → response

ASYNC PATH

Scheduler → Redis → ARQ Worker → LINE / PostgreSQL

06

SERVICE ARCHITECTURE

13 services. Clear boundaries.

Service catalog สร้างจาก SERVICE_LIST.md โดยตรง; Future คือ service ที่เอกสารระบุว่ายังไม่อยู่ใน runtime หลักหรือเป็น stub

SERVICE / FILERESPONSIBILITYDEPENDENCIESSTATE

AI Service

ai_service.py
เชื่อม Google Gemini และควบคุม prompting, conversation context, RAG และ tool callingCore intelligence
Conversation ServiceAppointment ServicePostgreSQL + pgvectorGoogle Gemini
Implemented

Conversation Service

conversation_service.py
จัดการ conversation lifecycle, message log, patient profile sync และ usage limitSupplies context and controls AI lifecycle
LINE ServiceAI ServicePostgreSQL
Implemented

Appointment Service

appointment_service.py
สร้าง ยกเลิก เลื่อนนัด คำนวณ slot, waitlist และ no-showTool target for appointment actions
AI ServiceFlex MessagePostgreSQL
Implemented

Broadcast Service

broadcast_service.py
ส่ง campaign แบบ segment, manual selection และ scheduledNo direct AI role documented
LINE ServiceARQ WorkerPostgreSQL
Implemented

Review Service

review_service.py
ส่ง feedback request หลัง appointment completed และสร้าง Google Review linkNo direct AI role documented
LINE ServiceARQ WorkerPostgreSQL
Implemented

LINE Service

line_service.py
Reply, push, profile, image handling และ token encryption สำหรับ LINE Messaging APIDelivers AI conversation
LINE Messaging APIChannel Adapter
Implemented

Channel Adapter

channel_adapter.py
abstraction ระหว่าง LINE และ Web Widget เพื่อลด coupling ใน bot handlerNormalizes AI inputs and outputs
LINE ServiceWeb Widget
Implemented

Flex Message

flex_message.py
สร้าง LINE Flex templates สำหรับ slot, appointment และ consentRenders tool results as actionable UI
Appointment ServiceLINE Service
Implemented

Billing Service

billing_service.py
จัดการบัตรและ subscription ของคลินิกผ่าน OmiseControls commercial access indirectly
Plan CatalogOmise
Implemented

Plan Catalog

plan_catalog.py
จัดการ trial/starter/growth/pro พร้อม AI message และ appointment quotasDefines AI usage quota
Billing ServiceConversation Service
Implemented

PromptPay Service

promptpay_service.py
สร้าง PromptPay QR สำหรับ payment flow ในอนาคตNo direct AI role
Future

Audit Service

audit_service.py
บันทึกการใช้งานและการแก้ไขค่าที่สำคัญของแอดมินGovernance support
PostgreSQL
Implemented

Notification Service

notification_service.py
Stub สำหรับ notification ภายในแอปพลิเคชันNo direct AI role documented
Future
07

END-TO-END FLOW

One message. Controlled execution.

LINE bot pipeline ตั้งแต่ signature verification, context, handoff gate, RAG ไปจนถึง tool loop และ durable log

STEP 04

Reason with knowledge

สร้างคำตอบที่อิงบริบทและข้อมูลคลินิก

INPUT
Message + context + Knowledge Base
PROCESSING
Gemini receives prompt, RAG context และ available tools
AI COMPONENT
Gemini · RAG · Prompting
OUTPUT
Response draft หรือ function call

BOOKING STATE FLOW

Detect booking intentChoose serviceChoose dateCheck availabilitySelect slotCollect patient infoConfirmCreate appointmentSend confirmation
08

AI INTELLIGENCE LAYER

Grounded enough to answer. Structured enough to act.

AI อยู่ในขอบเขตของ context, retrieval, service tools และ conversation state—ไม่ใช่ autonomous black box

GEMINI
01INPUT
02CONTEXT
03RETRIEVE
04REASON
05TOOL
06VALIDATE
07RESPOND

MODEL

Google Gemini

เป็น model provider ที่ระบุในระบบ ใช้รับ context, prompt, knowledge และ tools
Implemented

GROUNDING

Knowledge Base RAG

PostgreSQL + pgvector ทำหน้าที่ data/vector layer สำหรับ retrieval context
Implemented

ACTION

Function calling

AI เรียก business tools เช่นตรวจ slot และทำ appointment workflow โดยผลลัพธ์กลับเข้า model loop
Implemented

CONTROL

Human handoff

conversation state ทำให้ AI หยุดตอบเมื่อ staff รับช่วง และกลับมาทำงานหลัง resolve
Implemented
09

WHY THIS ARCHITECTURE

Decisions, not just technologies.

ทุก choice มีเหตุผล ทางเลือก และ trade-off ที่ต้องบริหาร

DECISION 01

Gemini + tool calling

WHY
คำถามของผู้ป่วยต้องการทั้งภาษาธรรมชาติและ action กับข้อมูลจริง
ALTERNATIVE
rule-based chatbot
TRADE-OFF
เพิ่ม model cost และต้องควบคุม output
RESULT
AI สนทนาและขอให้ระบบทำงานผ่าน service boundary
DECISION 02

RAG over static prompts

WHY
ความรู้เฉพาะคลินิกเปลี่ยนแปลงและควรแยกจาก prompt หลัก
ALTERNATIVE
ฝังข้อมูลทั้งหมดใน system prompt
TRADE-OFF
เพิ่ม retrieval pipeline และคุณภาพขึ้นกับ knowledge source
RESULT
Knowledge Base จัดการได้จาก Dashboard และส่ง context แบบมีขอบเขต
DECISION 03

Channel Adapter

WHY
LINE และ Web Widget มี event/output contract ต่างกัน
ALTERNATIVE
เขียน bot flow แยกตาม channel
TRADE-OFF
เพิ่ม abstraction layer หนึ่งชั้น
RESULT
bot handler ใช้ interface เดียวและลด channel coupling
DECISION 04

Redis + ARQ workers

WHY
reminder, campaign, no-show และ feedback ไม่ควรบล็อก API
ALTERNATIVE
ทำทั้งหมดใน request process
TRADE-OFF
ต้องดูแล queue และ worker เพิ่ม
RESULT
งานตามเวลาแยกจาก synchronous conversation path
10

SECURITY & GOVERNANCE

Be explicit about what exists—and what must come next.

Current controls แยกจาก Recommended controls เพื่อไม่ทำให้ maturity ของระบบถูกตีความเกินจริง

Implemented

Verified ingress

  • X-Line-Signature verification
  • Tenant & plan limit check
  • Token encryption in LINE Service
Implemented

Operational control

  • Human handoff state
  • Admin Audit Service
  • Conversation and usage logs
Recommended

AI safety controls

  • Prompt-injection test suite
  • Sensitive-data redaction policy
  • Structured-output validation at every tool boundary
Recommended

Reliability controls

  • Explicit retry / timeout policy
  • Model fallback strategy
  • Alerting and quality monitoring
11

PERFORMANCE & COST

Measure before optimizing.

ไม่มี latency, token หรือ cost metrics ในเอกสาร จึงนำเสนอเป็น measurement framework โดยไม่สร้าง KPI สมมติ

COST DRIVERCURRENT EVIDENCERECOMMENDED NEXT

Model usage

AI message quota exists per plan

Track tokens, latency and cost by tenant/model

Context size

Conversation context + RAG knowledge are provided

Measure retrieval relevance and trim low-value context

Background load

ARQ separates scheduled work from API

Add queue depth, execution time and failure-rate monitoring

Repeated work

Redis is present for cache/pubsub/ARQ

Define and measure safe cache policies for repeated reads

12

BUSINESS IMPACT

Before and after—without invented KPIs.

ผลกระทบเชิงคุณภาพที่อนุมานได้ตรงจาก architecture และ workflow; ตัวเลขควรเติมเมื่อมี production baseline

01

BEFORE

Channel-specific bot handling

AFTER

Channel Adapter normalizes LINE and Web Widget
Maintainability
02

BEFORE

Staff must remain in every conversation

AFTER

AI handles supported intents with explicit human handoff
Operational capacity
03

BEFORE

Time-based tasks compete with request work

AFTER

ARQ workers run reminders, campaigns, no-show and feedback
Automation
04

BEFORE

Clinic knowledge is disconnected from the model

AFTER

Knowledge Base feeds RAG context through pgvector
Response relevance
13

SCALABILITY

Scale the boundaries, not the complexity.

Current architecture มีจุดแยกที่เหมาะกับการ scale; กลยุทธ์ด้านล่างคือ proposed evolution ไม่ใช่สิ่งที่อ้างว่า implement แล้ว

01

API

CURRENT
FastAPI service layer
GROWTH CHALLENGE
Concurrent channels and tenant growth
SCALING STRATEGY
Horizontal replicas behind a load balancer
02

Jobs

CURRENT
Redis + ARQ worker
GROWTH CHALLENGE
Campaign and reminder bursts
SCALING STRATEGY
Worker pools, priority queues and idempotent jobs
03

Data

CURRENT
PostgreSQL + pgvector
GROWTH CHALLENGE
Transactional and retrieval load
SCALING STRATEGY
Indexes, connection pooling, read strategy and vector tuning
04

AI

CURRENT
Gemini with context/RAG/tools
GROWTH CHALLENGE
Latency, token cost and quota
SCALING STRATEGY
Model routing, context budgets, caching and evaluation gates
05

Operations

CURRENT
Audit and usage logs
GROWTH CHALLENGE
Cross-tenant incident diagnosis
SCALING STRATEGY
Central observability with tenant-aware SLOs
14

FUTURE ROADMAP

Foundation → confidence → scale → expansion.

Roadmap ให้ความสำคัญกับ measurement และ governance ก่อนขยาย AI footprint

01

NOW

Connected foundation

Implemented
  • LINE + Web Widget channels
  • Gemini RAG and tool calling
  • Appointment and handoff workflows
  • ARQ scheduled operations
02

NEXT

Measure & harden

Recommended
  • AI evaluation dataset
  • Token/latency/cost dashboard
  • Retry, timeout and fallback policy
  • Prompt-injection testing
03

SCALE

Tenant-aware operations

Future
  • Horizontal service scaling
  • Queue isolation and priorities
  • SLOs and alerting by tenant
  • Database/vector performance program
04

EXPAND

Governed AI growth

Future
  • Model routing by use case
  • Approval gates for high-risk tools
  • Knowledge quality lifecycle
  • Selective channel/payment expansion
15

FROM AI ENGINEER TO AI MANAGER

Manage the whole system of value.

AI leadership คือการเชื่อม business, model behavior, architecture, people, risk, cost และ governance ให้ตัดสินใจร่วมกันได้

AI
MANAGER
Understand · Design
Build · Scale · Manage
01

Business

เริ่มจาก patient journey และ operational value ก่อนเลือก AI

02

AI

จำกัดขอบเขต model ด้วย knowledge, tools และ handoff

03

Technology

แยก service boundary เพื่อให้ทีมเปลี่ยนและ scale ได้

04

People

กำหนดจุดที่ AI ทำงาน และจุดที่ staff ต้องรับผิดชอบ

05

Risk & Cost

วัด usage, ควบคุม tenant quota และออกแบบ guardrails

06

Governance

สร้าง auditability, evaluation และมาตรฐานก่อนขยาย use case

16

KEY TAKEAWAYS

ClinicBot, remembered in five ideas.

01

Business-driven AI

02

Grounded intelligence

03

Controlled automation

04

Scalable service boundaries

05

Governance before expansion

THIS IS NOT JUST A CHATBOT.

It is an AI operating model for clinic service.

UNDERSTAND DESIGN BUILD SCALE MANAGE