ThunderPhone 2.0 เปิดให้ใช้งานแล้วเริ่มใช้งานได้ด้วยตัวเอง ราคาเริ่มต้น 2 เซนต์ต่อนาที.อ่านประกาศเปิดตัว

Getting Started

เริ่มต้นใช้งานอย่างรวดเร็ว (API)

รับสายโทรศัพท์สายแรกด้วย AI เอเจนต์: รับคีย์ API สร้างเอเจนต์ จัดสรรหมายเลขโทรศัพท์ และโทรทดสอบแบบสด ทั้งหมดผ่าน REST API

คู่มือนี้จะแนะนำคำขอ REST ทั้งสี่รายการที่ใช้ในการรับสายโทรศัพท์สายแรกของคุณด้วย AI เอเจนต์

ขั้นตอนที่ 1: รับคีย์ API

  1. ลงชื่อเข้าใช้
  2. ไปที่คีย์

    ไปที่ องค์กร → คีย์ ในแดชบอร์ด

  3. สร้างคีย์

    คลิก สร้างคีย์ ตั้งชื่อ แล้วคัดลอกค่า sk_live_... คีย์แบบเต็มจะแสดง เพียงครั้งเดียว — จัดเก็บไว้ ในตัวจัดการข้อมูลลับของคุณทันที

ตลอดคู่มือนี้ ให้แทนที่ sk_live_YOUR_API_KEY ด้วยค่าที่คุณ เพิ่งคัดลอก คีย์จะระบุองค์กรของคุณโดยอัตโนมัติ ดังนั้นคุณไม่จำเป็นต้องใส่รหัสองค์กรใน URL

ขั้นตอนที่ 2: สร้างเอเจนต์

เอเจนต์กำหนดวิธีที่ AI จัดการบทสนทนา — พรอมป์ต์ เสียง ระดับผลิตภัณฑ์ เครื่องมือ และสิทธิ์การใช้งานวิดเจ็ต

cURL
curl -X POST https://api.thunderphone.com/v1/agents \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name":   "Customer Support",
    "prompt": "You are a friendly support agent for Acme Corp. Help with orders, returns, and product info. Be concise and helpful.",
    "voice":  "john",
    "product": "spark"
  }'
Python
import os, requests
 
agent = requests.post(
    "https://api.thunderphone.com/v1/agents",
    headers={"Authorization": f"Bearer {os.environ['THUNDERPHONE_API_KEY']}"},
    json={
        "name":   "Customer Support",
        "prompt": "You are a friendly support agent for Acme Corp. Help with orders, returns, and product info. Be concise and helpful.",
        "voice":  "john",
        "product": "spark",
    },
).json()
print("Agent id:", agent["id"])
Node.js
const agent = await fetch("https://api.thunderphone.com/v1/agents", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.THUNDERPHONE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name:    "Customer Support",
    prompt:  "You are a friendly support agent for Acme Corp. Help with orders, returns, and product info. Be concise and helpful.",
    voice:   "john",
    product: "spark",
  }),
}).then((r) => r.json());
console.log("Agent id:", agent.id);

ขั้นตอนที่ 3: จัดเตรียมหมายเลขโทรศัพท์

คำขอนี้ขอหมายเลขจาก ThunderPhone และกำหนดเอเจนต์ใหม่ของคุณเป็นตัวจัดการสายเรียกเข้า (หากต้องการนำหมายเลขของคุณเองจากผู้ให้บริการ VoIP มาใช้ โปรดดู การเชื่อมต่อ VoIP แทน)

cURL
# First provision
curl -X POST https://api.thunderphone.com/v1/phone-numbers \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"area_code": "415"}'
 
# Then assign the agent you created in Step 2
curl -X PATCH https://api.thunderphone.com/v1/phone-numbers/<id-from-previous> \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inbound_agent_id": 12}'
Python
number = requests.post(
    "https://api.thunderphone.com/v1/phone-numbers",
    headers={"Authorization": f"Bearer {os.environ['THUNDERPHONE_API_KEY']}"},
    json={"area_code": "415"},
).json()
requests.patch(
    f"https://api.thunderphone.com/v1/phone-numbers/{number['id']}",
    headers={"Authorization": f"Bearer {os.environ['THUNDERPHONE_API_KEY']}"},
    json={"inbound_agent_id": agent["id"]},
)
print("Your ThunderPhone number:", number["number"])

หมายเลขใหม่ของคุณเริ่มต้นด้วย status="provisioning" และเปลี่ยนเป็น active ภายในไม่กี่วินาที เมื่อคุณปิดเบราว์เซอร์ หมายเลขก็พร้อมรับสายแล้ว

ขั้นตอนที่ 4 (ไม่บังคับ): ตั้งค่าเว็บฮุก

สำหรับเหตุการณ์แบบเรียลไทม์ (การกำหนดเส้นทางสายแบบไดนามิก การประมวลผลหลังการโทร) ให้เพิ่มปลายทางเว็บฮุก สมัครรับเฉพาะเหตุการณ์ที่คุณต้องการ

curl -X POST https://api.thunderphone.com/v1/developer/webhook-endpoints \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label":  "Prod webhook",
    "url":    "https://your-server.com/thunderphone-webhook",
    "events": ["telephony.incoming", "telephony.complete"]
  }'

การตอบกลับมี secret ที่แสดงเพียงครั้งเดียว ให้คัดลอกไปยังระบบจัดการข้อมูลลับของคุณ ใช้ข้อมูลลับนั้นเพื่อตรวจสอบส่วนหัว X-ThunderPhone-Signature ในคำขอขาเข้า (ดู ภาพรวมเว็บฮุก)

ขั้นตอนที่ 5: ทดสอบเอเจนต์ของคุณ

โทรไปยังหมายเลขที่คุณเพิ่งจัดเตรียม เอเจนต์จะรับสาย แนะนำตัว และทำตามพรอมป์ต์ของคุณ

ตรวจสอบสายหลังจากสิ้นสุด:

curl https://api.thunderphone.com/v1/calls \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"

ดูรายละเอียดของสายที่ต้องการเพื่อดึงข้อความถอดเสียงและ URL ของไฟล์บันทึกเสียง:

curl https://api.thunderphone.com/v1/calls/{call_id}/transcript \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"
curl https://api.thunderphone.com/v1/calls/{call_id}/audio \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"

ขั้นตอนถัดไป