ตัวอย่างโค้ด
cURL
ลองทุกคำสั่งหลักจากหน้าจอ terminal
bash
export TAKKUB_API_KEY=tk_xxxxxxxx
export BASE=https://office.takkub.com/api/v1
# แชตที่รอตอบ
curl "$BASE/threads?state=waiting" -H "Authorization: Bearer $TAKKUB_API_KEY"
# ข้อความย้อนหลัง
curl "$BASE/threads/1042/messages?limit=30" -H "Authorization: Bearer $TAKKUB_API_KEY"
# ตอบลูกค้า
curl -X POST "$BASE/threads/1042/messages" \
-H "Authorization: Bearer $TAKKUB_API_KEY" -H "Content-Type: application/json" \
-d '{"text":"สวัสดีค่ะ","client_id":"hello-1"}'
# ปิดงาน
curl -X POST "$BASE/threads/1042/status" \
-H "Authorization: Bearer $TAKKUB_API_KEY" -H "Content-Type: application/json" \
-d '{"status":"done"}'