เอกสารอ้างอิง API
สร้างการเชื่อมต่อแบบกำหนดเองด้วย Asyntai REST API
ต้องใช้แผนชำระเงิน: การเข้าถึง API มีให้ในแผน Starter, Standard และ Pro ดูราคา
ภาพรวม
The Asyntai API allows you to integrate AI-powered customer support into any application. Send messages and receive intelligent responses grounded in your website content and knowledge base.
การยืนยันตัวตน
คำขอ API ทั้งหมดต้องมีการยืนยันตัวตนโดยใช้คีย์ API ของคุณ คุณสามารถรับคีย์ API จากหน้าการตั้งค่า API
รวมคีย์ API ของคุณในคำขอโดยใช้วิธีใดวิธีหนึ่งต่อไปนี้:
- ส่วนหัว Authorization (แนะนำ):
Authorization: Bearer YOUR_API_KEY - ส่วนหัว X-API-Key:
X-API-Key: YOUR_API_KEY
เก็บคีย์ API ของคุณเป็นความลับ ใครก็ตามที่มีคีย์ของคุณสามารถเข้าถึงบัญชีของคุณผ่าน API ได้ อย่าเปิดเผยในโค้ดฝั่งไคลเอนต์
URL พื้นฐาน
https://asyntai.com/api/v1/
เอนด์พอยท์
POST /chat/
ส่งข้อความและรับการตอบสนองที่สร้างโดย AI
เนื้อหาคำขอ
{
"message": "What are your business hours?",
"session_id": "user_123", // optional
"website_id": 1 // optional
}
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
message |
string | ใช่ | ข้อความของผู้ใช้ที่จะส่งไปยัง AI |
session_id |
string | ไม่ | ตัวระบุเฉพาะสำหรับการสนทนา ใช้ session_id เดียวกันเพื่อรักษาประวัติการสนทนา |
website_id |
integer | ไม่ | ID เว็บไซต์เฉพาะ หากไม่ระบุ จะใช้เว็บไซต์หลักของคุณ |
การตอบกลับ
{
"success": true,
"response": "Our business hours are Monday-Friday, 9 AM to 5 PM EST.",
"session_id": "user_123"
}
ตัวอย่าง (cURL)
curl -X POST https://asyntai.com/api/v1/chat/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "What are your business hours?", "session_id": "user_123"}'
ตัวอย่าง (Python)
import requests
response = requests.post(
"https://asyntai.com/api/v1/chat/",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"message": "What are your business hours?",
"session_id": "user_123"
}
)
data = response.json()
print(data["response"])
ตัวอย่าง (JavaScript)
const response = await fetch("https://asyntai.com/api/v1/chat/", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
message: "What are your business hours?",
session_id: "user_123"
})
});
const data = await response.json();
console.log(data.response);
GET /websites/
แสดงรายการเว็บไซต์ทั้งหมดที่เชื่อมโยงกับบัญชีของคุณ
การตอบกลับ
{
"success": true,
"websites": [
{
"id": 1,
"name": "My Website",
"domain": "example.com",
"is_primary": true
}
]
}
ตัวอย่าง (cURL)
curl https://asyntai.com/api/v1/websites/ \
-H "Authorization: Bearer YOUR_API_KEY"
POST /websites/
Create a new AI agent. This does the same thing as adding a website in your dashboard: it makes the agent, reads your site, and writes the first draft of the AI instructions.
Use this to set up customers from your own software. You get back the widget ID and the code to put on the website.
เนื้อหาคำขอ
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
domain |
string | Required. The website address, for example example.com |
name |
string | Optional. A display name for the agent. Useful when one website has several agents. |
crawl |
boolean | Optional, true by default. Set it to false to create the agent without reading the website. Nothing is crawled and no instructions are written. |
force |
boolean | Optional, false by default. Set it to true to add a website you already have. The copy is stored with a number after it. |
การตอบกลับ
{
"success": true,
"website": {
"id": 42,
"domain": "example.com",
"name": "Support agent",
"widget_id": "asyntai_ab12cd34ef56",
"is_primary": true,
"crawl_started": true,
"instructions_status": "generating",
"job_id": "8f2c1e90-..."
},
"embed_code": "<script>...</script>"
}
ตัวอย่าง (cURL)
curl -X POST https://asyntai.com/api/v1/websites/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"domain": "example.com", "name": "Support agent"}'
Reading a website takes a few minutes, so this call answers straight away. Check when the agent is ready with the next endpoint.
Errors
| Code | Meaning |
|---|---|
403 |
You have reached the number of websites your plan allows. The answer tells you the limit. |
409 |
Your account already has this website. Send force as true to add it again. |
GET /websites/{id}/
Get one website and see whether it is ready. Use this after you create an agent, to wait until the website has been read and the AI instructions are written.
การตอบกลับ
{
"success": true,
"website": {
"id": 42,
"domain": "example.com",
"name": "Support agent",
"widget_id": "asyntai_ab12cd34ef56",
"is_primary": true,
"created_at": "2026-08-11T09:12:00+00:00",
"ready": true,
"instructions": {
"status": "completed",
"has_instructions": true,
"characters": 3421
},
"crawl": {
"job_id": "8f2c1e90-...",
"status": "completed",
"pages_crawled": 47,
"pages_found": 50,
"max_pages": 50,
"completed_at": "2026-08-11T09:15:31+00:00",
"error": ""
},
"knowledge_items": 47
},
"embed_code": "<script>...</script>"
}
The ready field is true when nothing is still running. A crawl that failed also counts as ready, because it has finished. Look at the crawl status to see what happened.
ตัวอย่าง (cURL)
curl https://asyntai.com/api/v1/websites/42/ \
-H "Authorization: Bearer YOUR_API_KEY"
GET PATCH /websites/{id}/settings/
Read or change the chat widget settings for one website. These are the same settings you see on the Customize page: colours, the name of the assistant, the first message, lead capture, and everything else.
Reading the settings
A GET request returns every setting with its current value, plus a locked list. Locked shows the settings your plan cannot change, and which plans they need.
{
"success": true,
"settings": {
"ai_support_name": "AI Assistant",
"widget_color": "#6366f1",
"initial_message": "Hi, how can I help you?",
"hide_branding": false,
"...": "..."
},
"locked": {
"hide_branding": ["pro", "enterprise"],
"widget_style": ["pro", "enterprise"]
}
}
Changing the settings
A PATCH request changes only the settings you send. Everything you leave out stays as it is.
curl -X PATCH https://asyntai.com/api/v1/websites/42/settings/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ai_support_name": "Ava", "widget_color": "#0f172a", "use_emoji": true}'
{
"success": true,
"updated": ["ai_support_name", "use_emoji", "widget_color"],
"settings": { "...": "..." },
"locked": { "...": "..." }
}
Plans
Each setting needs its own plan, the same as in the dashboard. For example, hiding the Asyntai branding needs the Pro plan, and voice input needs Standard.
| Plan needed | การตั้งค่า | Examples |
|---|---|---|
| Any paid plan | 25 | widget_color, ai_support_name, initial_message |
| Starter ขึ้นไป | 22 | profile_picture, conversation_starters_enabled |
| Standard ขึ้นไป | 25 | speech_to_text_enabled, image_vision_enabled, escalation_enabled |
| Pro | 6 | hide_branding, widget_style |
If you send a setting your plan does not allow, the whole request is refused with code 403 and nothing is saved. The same happens if any value is wrong, for example a colour that is not a hex code. Your settings never end up half changed.
GET PUT /websites/{id}/instructions/
Read or replace the AI instructions for one website. These are the rules that tell the assistant who it is, what it may say, and what it must not say. They are the same instructions you edit in the dashboard.
Reading
{
"success": true,
"instructions": "You are the support agent for Acme Tools...",
"characters": 1979,
"version": 7,
"mode": "instructions",
"ask_questions": true,
"generation_status": "completed",
"being_edited_by": null
}
Replacing
A PUT request replaces the whole text, the same as saving in the dashboard. There is no append mode. To add a paragraph, read the instructions, add your text, then write it back.
curl -X PUT https://asyntai.com/api/v1/websites/42/instructions/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"instructions": "You are the support agent for Acme Tools...", "version": 7}'
เนื้อหาคำขอ
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
instructions |
string | Required. The complete new text. It replaces everything that was there. |
version |
number | Optional but recommended. The version you read. If somebody changed the instructions since then, your write is refused instead of overwriting their work. |
mode |
string | Optional. Either instructions or general. |
ask_questions |
boolean | Optional. Whether the assistant asks a follow-up question at the end of its answers. |
force |
boolean | Optional, false by default. Needed only when your new text is less than half the length of the current text. |
How your instructions are protected
Instructions can take hours to write, so a write can be refused to protect them:
| Code | Meaning |
|---|---|
400 |
Your new text is less than half the length of the current text. This catches a script that sends empty or cut-off text over instructions somebody spent hours on. Send force as true if you meant it. |
409 |
The instructions changed after you read them. Read them again, apply your change, then write. |
423 |
Somebody is editing the instructions in the dashboard right now. The answer tells you who. Try again in a couple of minutes. |
Every change also saves a copy of the previous text, so an earlier version can always be restored from the dashboard.
GET /conversations/
ดึงประวัติการสนทนาสำหรับเซสชันเฉพาะ
พารามิเตอร์คิวรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
session_id |
string | ใช่ | ID เซสชันที่จะดึงประวัติ |
limit |
integer | ไม่ | จำนวนข้อความสูงสุดที่จะส่งคืน (ค่าเริ่มต้น: 50, สูงสุด: 100) |
การตอบกลับ
{
"success": true,
"session_id": "user_123",
"messages": [
{
"role": "user",
"content": "What are your business hours?",
"timestamp": "2024-01-15T10:30:00Z"
},
{
"role": "assistant",
"content": "Our business hours are Monday-Friday, 9 AM to 5 PM EST.",
"timestamp": "2024-01-15T10:30:01Z",
"sender_type": "ai",
"agent_name": null,
"response_time_ms": 1840.5
}
]
}
คำถามและคำตอบถูกเก็บไว้ในระเบียนเดียวกัน ทั้งสองจึงมี timestamp เดียวกัน อย่านำค่าหนึ่งลบอีกค่าหนึ่งเพื่อวัดความเร็วในการตอบ เพราะผลลัพธ์จะเป็นศูนย์เสมอ ให้ใช้ response_time_ms ซึ่งเป็นเวลาจริงที่ใช้ในการตอบ หน่วยเป็นมิลลิวินาที
sender_type มีค่าเป็น ai เมื่อแชตบอตเป็นผู้ตอบ และเป็น human เมื่อเจ้าหน้าที่ของคุณเข้ามารับช่วงการสนทนา ส่วน agent_name เก็บชื่อที่แสดงของเจ้าหน้าที่คนนั้น
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/conversations/?session_id=user_123&limit=20" \
-H "Authorization: Bearer YOUR_API_KEY"
GET /sessions/
แสดงรายการเซสชันแชทล่าสุดของคุณ ใช้เพื่อค้นหา ID เซสชัน ซึ่งคุณสามารถส่งไปยัง /conversations/ เพื่อดึงประวัติข้อความทั้งหมด
พารามิเตอร์คิวรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
limit |
integer | ไม่ | จำนวนเซสชันล่าสุดที่จะส่งคืน (ค่าเริ่มต้น: 20, สูงสุด: 100) |
website_id |
string | ไม่ | กรองเซสชันตาม ID เว็บไซต์เฉพาะ |
source |
string | ไม่ | กรองตามแหล่งที่มาของเซสชัน: widget, api, whatsapp, instagram, messenger, gorgias, freshchat, zapier |
การตอบกลับ
{
"success": true,
"sessions": [
{
"session_id": "session_abc123def",
"source": "widget",
"message_count": 5,
"first_message": "What are your business hours?",
"first_message_at": "2024-01-15T10:30:00Z",
"last_message_at": "2024-01-15T10:35:00Z",
"first_response_time_ms": 1840.5,
"first_human_response_at": null,
"started_at": "2024-01-15T10:29:58Z",
"ended_at": "2024-01-15T10:41:12Z",
"taken_over_at": null,
"website_domain": "example.com"
}
]
}
ฟิลด์เวลาสำหรับการทำรายงาน
| ฟิลด์ | คำอธิบาย |
|---|---|
started_at |
เวลาที่ผู้เข้าชมเปิดการสนทนา ใช้ได้กับเซสชันของวิดเจ็ตเท่านั้น เพราะเซสชันที่สร้างผ่าน API จะไม่เปิดวิดเจ็ต |
first_message_at |
เวลาที่บันทึกข้อความแรกของการสนทนา |
first_response_time_ms |
เวลาที่ใช้ในการตอบครั้งแรก หน่วยเป็นมิลลิวินาที ใช้ค่านี้สำหรับเวลาตอบกลับครั้งแรก |
first_human_response_at |
เวลาที่เจ้าหน้าที่ของคุณส่งคำตอบแรก ค่าจะเป็น null เมื่อแชตบอตดูแลการสนทนาทั้งหมด |
taken_over_at |
เวลาที่เจ้าหน้าที่รับช่วงการสนทนาต่อจากแชตบอต |
last_message_at |
เวลาที่บันทึกข้อความสุดท้ายของการสนทนา |
ended_at |
เวลาที่ผู้เข้าชมออกจากการสนทนา การสนทนาไม่มีสถานะแก้ไขแล้วหรือปิดแล้ว เพราะผู้เข้าชมสามารถกลับมาถามคำถามใหม่ได้เสมอ |
เวลาทั้งหมดเป็น UTC และใช้รูปแบบ ISO 8601 คุณไม่สามารถเปลี่ยนเขตเวลาได้ โปรดแปลงค่าในเครื่องมือทำรายงานของคุณเอง
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/sessions/?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
GET /leads/
ดึงข้อมูลลีดที่รวบรวม — ที่อยู่อีเมลและหมายเลขโทรศัพท์ที่ผู้เยี่ยมชมส่งระหว่างการสนทนาแชท
พารามิเตอร์คิวรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
limit |
integer | ไม่ | จำนวนลีดที่จะส่งคืน (ค่าเริ่มต้น: 50, สูงสุด: 100) |
website_id |
string | ไม่ | กรองลีดตาม ID เว็บไซต์ที่ระบุ |
การตอบกลับ
{
"success": true,
"leads": [
{
"session_id": "session_abc123def",
"email": "[email protected]",
"phone": "+1234567890",
"page_url": "https://example.com/pricing",
"started_at": "2024-01-15T10:30:00Z"
}
]
}
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
session_id |
string | ID เซสชันแชท ส่งค่านี้ไปที่ /conversations/ เพื่อดูประวัติการแชทฉบับเต็ม |
email |
สตริงหรือ null | ที่อยู่อีเมลที่ผู้เยี่ยมชมให้มา หรือ null หากไม่ได้รวบรวม |
phone |
สตริงหรือ null | หมายเลขโทรศัพท์ที่ผู้เยี่ยมชมให้มา หรือ null หากไม่ได้รวบรวม |
page_url |
สตริงหรือ null | URL ของหน้าที่ผู้เยี่ยมชมกำลังแชท |
started_at |
string | เวลาประทับ ISO 8601 ของเวลาที่เซสชันแชทเริ่มต้น |
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/leads/?limit=20" \
-H "Authorization: Bearer YOUR_API_KEY"
ตัวอย่าง (Python)
import requests
response = requests.get(
"https://asyntai.com/api/v1/leads/",
headers={"Authorization": "Bearer YOUR_API_KEY"},
params={"limit": 20}
)
leads = response.json()["leads"]
for lead in leads:
print(f"{lead['email'] or ''} | {lead['phone'] or ''}")
GET /account/
รับข้อมูลบัญชีและสถิติการใช้งานของคุณ
การตอบกลับ
{
"success": true,
"account": {
"email": "[email protected]",
"plan": "starter",
"messages_used": 150,
"messages_limit": 2500
}
}
ตัวอย่าง (cURL)
curl https://asyntai.com/api/v1/account/ \
-H "Authorization: Bearer YOUR_API_KEY"
มีหลายเว็บไซต์? เอนด์พอยท์ฐานความรู้จะใช้เว็บไซต์หลักของคุณเป็นค่าเริ่มต้น หากคุณมีหลายเว็บไซต์ ให้ส่ง website_id เพื่อกำหนดเป้าหมายเว็บไซต์เฉพาะ คุณสามารถค้นหา ID เว็บไซต์ได้โดยใช้ GET /websites/.
ขีดจำกัดการอัปโหลดรายวัน: การอัปโหลดฐานความรู้ (ข้อความ, URL, สเปรดชีต) มีขีดจำกัดอักขระรายวันตามแผนของคุณ ซึ่งใช้กับเนื้อหาทั้งหมดที่อัปโหลดผ่านเอนด์พอยท์ฐานความรู้ทั้งหมดต่อวัน
| แผน | อักขระ/วัน |
|---|---|
| Starter | 300,000 |
| Standard | 1,500,000 |
| Pro | 6,000,000 |
GET /knowledge/
แสดงรายการฐานความรู้ของคุณ สิ่งเหล่านี้คือแหล่งเนื้อหาที่แชทบอท AI ของคุณใช้ในการตอบคำถาม
พารามิเตอร์คิวรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
limit |
integer | ไม่ | จำนวนรายการที่จะส่งคืน (ค่าเริ่มต้น: 50, สูงสุด: 100) |
website_id |
string | ไม่ | กรองตาม ID เว็บไซต์ (ค่าเริ่มต้นคือเว็บไซต์หลักของคุณ) |
การตอบกลับ
{
"success": true,
"entries": [
{
"id": "abc-123-def",
"type": "text",
"title": "Business Hours",
"description": "Manual text content (150 words)",
"created_at": "2024-01-15T10:30:00Z"
},
{
"id": "ghi-456-jkl",
"type": "url",
"title": "About Us - Example",
"description": "Content from https://example.com/about",
"created_at": "2024-01-14T09:00:00Z"
}
]
}
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/knowledge/?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
POST /knowledge/text/
เพิ่มเนื้อหาข้อความแบบกำหนดเองลงในฐานความรู้ของคุณ AI จะใช้สิ่งนี้เพื่อตอบคำถามของผู้เยี่ยมชม
เนื้อหาคำขอ
{
"title": "Return Policy",
"content": "We offer a 30-day return policy on all items. Items must be unused and in original packaging. Refunds are processed within 5-7 business days.",
"website_id": "123"
}
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
title |
string | ใช่ | ชื่อเรื่องสำหรับรายการความรู้นี้ |
content |
string | ใช่ | เนื้อหาข้อความ (อย่างน้อย 10 อักขระ) |
website_id |
string | ไม่ | เว็บไซต์เป้าหมาย (ค่าเริ่มต้นคือเว็บไซต์หลักของคุณ) |
การตอบกลับ
{
"success": true,
"id": "abc-123-def",
"title": "Return Policy",
"chunks_created": 1
}
ตัวอย่าง (cURL)
curl -X POST "https://asyntai.com/api/v1/knowledge/text/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Return Policy", "content": "We offer a 30-day return policy..."}'
POST /knowledge/url/
เพิ่มหน้าเว็บลงในฐานความรู้ของคุณ เนื้อหาจะถูกดึงและแยกออกโดยอัตโนมัติ
เนื้อหาคำขอ
{
"url": "https://example.com/faq",
"website_id": "123"
}
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
url |
string | ใช่ | URL ที่จะดึงเนื้อหา |
website_id |
string | ไม่ | เว็บไซต์เป้าหมาย (ค่าเริ่มต้นคือเว็บไซต์หลักของคุณ) |
การตอบกลับ
{
"success": true,
"id": "abc-123-def",
"title": "FAQ - Example",
"url": "https://example.com/faq",
"chunks_created": 5
}
ตัวอย่าง (cURL)
curl -X POST "https://asyntai.com/api/v1/knowledge/url/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/faq"}'
POST /knowledge/spreadsheet/
อัปโหลดสเปรดชีต CSV หรือ Excel (.xlsx) ลงในฐานความรู้ของคุณ แต่ละแถวจะกลายเป็นรายการความรู้แยกต่างหาก เหมาะสำหรับแคตตาล็อกสินค้า รายการคำถามที่พบบ่อย ตารางราคา และไดเรกทอรี
คำขอ
ส่งเป็น multipart/form-data (อัปโหลดไฟล์) ไม่ใช่ JSON
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
file |
file | ใช่ | ไฟล์ .csv หรือ .xlsx แถวแรกต้องเป็นหัวคอลัมน์ จำนวนแถวสูงสุดต่อการอัปโหลด: Starter 500, Standard 2,000, Pro 10,000 แถวที่เกินจะถูกตัดทิ้ง |
website_id |
string | ไม่ | เว็บไซต์เป้าหมาย (ค่าเริ่มต้นคือเว็บไซต์หลักของคุณ) |
การตอบกลับ
{
"success": true,
"id": "abc-123-def",
"title": "products.csv",
"rows_processed": 15,
"chunks_created": 15
}
ตัวอย่าง (cURL)
curl -X POST "https://asyntai.com/api/v1/knowledge/spreadsheet/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "[email protected]"
GET /knowledge/{id}/
อ่านรายการหนึ่งรายการในฐานความรู้ รวมถึงข้อความที่จัดเก็บไว้สำหรับรายการนั้น ค่า id มาจากการตอบกลับของ GET /knowledge/
ระบบจะส่งคืนเนื้อหาสำหรับรายการที่คุณเพิ่มเอง ได้แก่ ข้อความ ไฟล์ สเปรดชีต URL เดี่ยว และวิดีโอ การรวบรวมข้อมูลเว็บไซต์จะแสดงในรายการ แต่จะไม่ส่งคืนหน้าเว็บ เพราะแหล่งที่มาคือเว็บไซต์สาธารณะของคุณเอง ในกรณีนั้น content จะเป็น null และฟิลด์ reason จะอธิบายเหตุผล
การตอบกลับ
{
"success": true,
"id": "abc-123-def",
"type": "text",
"title": "Business Hours",
"description": "Manual text content (150 words)",
"created_at": "2024-01-15T10:30:00Z",
"chunks_count": 3,
"content": "We are open Monday to Friday, 9am to 5pm...",
"content_available": true,
"char_count": 43
}
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
DELETE /knowledge/{id}/
ลบรายการฐานความรู้ id สามารถค้นหาได้จากการตอบกลับ GET /knowledge/
การตอบกลับ
{
"success": true,
"message": "Knowledge base entry deleted"
}
ตัวอย่าง (cURL)
curl -X DELETE "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
เคล็ดลับ: คุณยังสามารถจัดการ webhooks ได้จาก การตั้งค่า API หน้าเว็บโดยไม่ต้องเขียนโค้ดใดๆ
GET /webhooks/
แสดงรายการ webhooks ที่ลงทะเบียนของคุณ
การตอบกลับ
{
"success": true,
"webhooks": [
{
"id": "abc-123-def",
"url": "https://example.com/webhook",
"events": ["message.received", "escalation.requested"],
"is_active": true,
"created_at": "2024-01-15T10:30:00Z"
}
]
}
ตัวอย่าง (cURL)
curl "https://asyntai.com/api/v1/webhooks/" \
-H "Authorization: Bearer YOUR_API_KEY"
POST /webhooks/
ลงทะเบียน webhook ใหม่เพื่อรับการแจ้งเตือนเหตุการณ์แบบเรียลไทม์
เหตุการณ์ที่มี
| เหตุการณ์ | คำอธิบาย |
|---|---|
message.received |
ผู้เยี่ยมชมส่งข้อความและได้รับการตอบกลับ |
conversation.started |
เซสชันแชทใหม่เริ่มต้นแล้ว |
escalation.requested |
AI ทริกเกอร์การส่งต่อไปยังเจ้าหน้าที่ |
takeover.started |
เจ้าหน้าที่เข้าควบคุมเซสชันแชท |
เนื้อหาคำขอ
{
"url": "https://example.com/webhook",
"events": ["message.received", "escalation.requested"],
"website_id": "123"
}
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
url |
string | ใช่ | URL HTTPS สำหรับรับคำขอ POST ของ webhook |
events |
array | ใช่ | รายการเหตุการณ์ที่จะสมัครรับ (ดูตารางด้านบน) |
website_id |
string | ไม่ | เว็บไซต์เป้าหมาย (ค่าเริ่มต้นคือเว็บไซต์หลักของคุณ) |
การตอบกลับ
{
"success": true,
"webhook": {
"id": "abc-123-def",
"url": "https://example.com/webhook",
"events": ["message.received", "escalation.requested"],
"secret": "whsec_abc123...",
"created_at": "2024-01-15T10:30:00Z"
}
}
การตรวจสอบ webhooks: แต่ละ webhook ประกอบด้วย secret (แสดงเฉพาะเมื่อสร้าง) ทุกการ POST ไปยัง URL ของคุณจะมี X-Webhook-Signature ส่วนหัว -- HMAC-SHA256 ของเนื้อหาคำขอที่ลงนามด้วยซีเคร็ตของคุณ
ตัวอย่าง (cURL)
curl -X POST "https://asyntai.com/api/v1/webhooks/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/webhook", "events": ["message.received"]}'
DELETE /webhooks/{id}/
ลบ webhook id สามารถค้นหาได้จากการตอบกลับ GET /webhooks/
การตอบกลับ
{
"success": true,
"message": "Webhook deleted"
}
ตัวอย่าง (cURL)
curl -X DELETE "https://asyntai.com/api/v1/webhooks/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
การตอบกลับข้อผิดพลาด
การตอบกลับข้อผิดพลาดทั้งหมดใช้รูปแบบนี้:
{
"success": false,
"error": "Error message describing what went wrong"
}
| รหัสสถานะ | คำอธิบาย |
|---|---|
400 |
คำขอไม่ถูกต้อง - พารามิเตอร์ไม่ถูกต้องหรือขาดฟิลด์ที่จำเป็น |
401 |
ไม่ได้รับอนุญาต - คีย์ API ไม่ถูกต้องหรือหายไป |
429 |
คำขอมากเกินไป - ถึงขีดจำกัดข้อความสำหรับแผนของคุณแล้ว |
503 |
บริการไม่พร้อมใช้งาน - บริการ AI ไม่พร้อมใช้งานชั่วคราว |
ขีดจำกัดอัตรา
การใช้งาน API ถูกจำกัดตามแผนสมัครสมาชิกของคุณ:
- Free: 100 ข้อความ/เดือน
- Starter ($39/เดือน): 2,500 ข้อความ/เดือน
- Standard ($139/เดือน): 15,000 ข้อความ/เดือน
- Pro ($449/เดือน): 50,000 ข้อความ/เดือน
ต้องการความช่วยเหลือ?
หากคุณมีคำถามหรือพบปัญหา ติดต่อเราได้ที่ [email protected].