โหมด Webhook
โหมด Webhook
ปัจจุบัน GPTBots Agent รองรับโหมดการตอบกลับข้อความ ได้แก่ blocking, streaming และ webhook เมื่อนักพัฒนาเลือกใช้ โหมด webhook เพื่อรับข้อความตอบกลับ เนื้อหาข้อความที่ได้จาก Agent หรือเจ้าหน้าที่บริการลูกค้าจะถูกส่งไปยัง webhook address ที่กำหนดไว้
วิธีการร้องขอ
POST
Endpoint
กำหนดที่อยู่สำหรับรับข้อความของคุณได้ที่หน้า Agent - Integration - API - webhook
การยืนยันตัวตน
ดูรายละเอียดวิธีการยืนยันตัวตนได้ที่หัวข้อภาพรวม API
คำขอ
ตัวอย่างคำขอ
curl -X POST 'YOUR_API_URL' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"message_id": "65a4ccfC7ce58e728d5897e0",
"message_type": "ANSWER",
"text": "Hi, is there anything I can help you?",
"flow_output": [
{
"content": "你好",
"branch": "1",
"from_component_name": "User Input"
}
],
"create_time": 1679587005,
"conversation_id": "657303a8a764d47094874bbe"
}'
curl -X POST 'YOUR_API_URL' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"message_id": "65a4ccfC7ce58e728d5897e0",
"message_type": "ANSWER",
"text": "Hi, is there anything I can help you?",
"flow_output": [
{
"content": "你好",
"branch": "1",
"from_component_name": "User Input"
}
],
"create_time": 1679587005,
"conversation_id": "657303a8a764d47094874bbe"
}'
บล็อกโค้ดนี้ในหน้าต่างลอย
Request Headers
| ฟิลด์ | ประเภท | รายละเอียด |
|---|---|---|
| Authorization | Bearer หรือ Basic ${token} | ใช้ Authorization: Bearer หรือ Basic ${token} สำหรับการยืนยันตัวตน รับ token ได้จากหน้า API Key |
| Content-Type | application/json | ประเภทข้อมูล ให้ใช้ค่า application/json |
พารามิเตอร์คำขอ
| ฟิลด์ | ประเภท | รายละเอียด |
|---|---|---|
| message_id | string | รหัสข้อความที่ไม่ซ้ำกัน |
| message_type | string | ประเภทข้อความ เช่น ANSWER, QUESTION |
| text | string | เนื้อหาข้อความที่ Agent ตอบกลับ |
| flow_output | JSON Array | เนื้อหาคำตอบของ Agent ในโหมด Flow |
| content | string | ข้อความตอบกลับจากคอมโพเนนต์ Agent ในโหมด Flow |
| branch | string | สาขาของ Agent ในโหมด Flow |
| from_component_name | string | ชื่อคอมโพเนนต์ต้นทางของ Agent ในโหมด Flow |
| create_time | long | เวลาที่สร้างข้อความตอบกลับ (timestamp) |
| conversation_id | string | รหัสการสนทนา |
การตอบกลับ
ตัวอย่างการตอบกลับ
{
"code": 200,
"msg": "success"
}
{
"code": 200,
"msg": "success"
}
บล็อกโค้ดนี้ในหน้าต่างลอย
