ข้ามไปยังเนื้อหา

paramsSchema และ agentParams

agent แต่ละตัวระบุไว้ใน paramsSchema ว่าต้องรู้ข้อมูลอะไรของคนที่จะโทรหา เช่น ชื่อ ยอดเงิน วันครบกำหนด ตอนสร้าง campaign ให้ส่งข้อมูลเหล่านี้ของ recipient แต่ละคนมาใน agentParams แล้ว agent จะเอาไปใช้ตอนคุย เช่น “คุณสมชายมียอดค้างชำระ 1,500 บาทค่ะ”

ดู schema นี้ได้จาก ดูรายการ Agent เป็น schema ของ version ที่ publish แล้วของ agent แต่ละ key คือชื่อ parameter

{
"customer_name": { "type": "text", "required": true, "description": "Customer first name" },
"amount_due": { "type": "number", "required": true, "description": "Outstanding amount in baht" },
"is_vip": { "type": "boolean", "required": false }
}
Property คำอธิบาย
type text, number หรือ boolean
required ถ้าเป็น true recipient ทุกคนต้องมี key นี้
description ค่านี้หมายถึงอะไร
default ไม่บังคับ เป็นค่าที่ agent ใช้แทน เมื่อ agentParams ของ recipient ไม่มี key นี้

ตัวอย่างตาม schema ด้านบน

✅ ถูกต้อง
{ "tel": "0812345678", "customerName": "Somchai", "agentParams": { "customer_name": "Somchai", "amount_due": 1500 } }
❌ ไม่ถูกต้อง
{ "tel": "0812345678", "agentParams": { "customer_name": "Somchai", "amount_due": "1500" } }

ตัวอย่างที่สองใช้ไม่ได้ เพราะ amount_due เป็น string ("1500") แต่ schema กำหนดให้เป็น number ระบบจะตอบ error ว่า Field amount_due must be a number, got string

type ค่าที่ต้องส่งใน JSON ตัวอย่าง
text string "Somchai", "2026-10-05"
number ตัวเลข ไม่ต้องใส่เครื่องหมายคำพูด 1500, 12.5
boolean true หรือ false ไม่ต้องใส่เครื่องหมายคำพูด true
  • ระบบเช็ก type เฉพาะ key ที่ required ส่วน key ที่ไม่บังคับ (เช่น is_vip) ระบบไม่เช็ก แต่ก็ควรส่ง type ให้ถูก ไม่อย่างนั้น agent อาจเข้าใจค่าผิด
  • ส่ง key อื่นที่ไม่มีใน schema มาด้วยได้ ระบบจะเก็บไว้และส่งกลับมาให้ แต่ agent อาจไม่ได้ใช้
  • ถ้า recipient คนไหนข้อมูลไม่ถูกต้อง request สร้าง campaign จะไม่ผ่านทั้ง request และระบบจะไม่สร้างอะไรเลย ดู สร้าง Campaign → Error