త్వరిత ప్రారంభం (API)

ఈ గైడ్ మీ మొదటి ఫోన్ కాల్‌కు AI ఏజెంట్‌తో సమాధానం ఇవ్వడానికి అవసరమైన నాలుగు REST కాల్‌లను వివరిస్తుంది.

దశ 1: API కీని పొందండి

  1. లాగిన్ అవ్వండి

    app.thunderphone.com తెరవండి.

  2. కీలకు వెళ్లండి

    డ్యాష్‌బోర్డ్‌లో సంస్థ → కీలుకి వెళ్లండి.

  3. కీని సృష్టించండి

    కీని సృష్టించండి క్లిక్ చేసి, దానికి పేరు ఇచ్చి, sk_live_... విలువను కాపీ చేయండి. ముడి కీ ఒక్కసారి మాత్రమే చూపబడుతుంది — దాన్ని వెంటనే మీ సీక్రెట్ మేనేజర్‌లో నిల్వ చేయండి.

ఈ గైడ్ అంతటా, sk_live_YOUR_API_KEY స్థానంలో మీరు ఇప్పుడే కాపీ చేసిన విలువను ఉంచండి. కీ మీ సంస్థను స్వయంచాలకంగా గుర్తిస్తుంది కాబట్టి, మీరు ఎప్పుడూ URLలలో సంస్థ idని ఉంచాల్సిన అవసరం లేదు.

దశ 2: ఏజెంట్‌ను సృష్టించండి

AI సంభాషణలను ఎలా నిర్వహించాలో ఏజెంట్ నిర్వచిస్తుంది — prompt, వాయిస్, ఉత్పత్తి స్థాయి, టూల్స్ మరియు విడ్జెట్ అర్హత.

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"
  }'
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"])
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 కనెక్షన్‌లు చూడండి.)

# 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}'
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: మీ ఏజెంట్‌ను పరీక్షించండి

మీరు ఇప్పుడే ప్రొవిజన్ చేసిన నంబర్‌కు కాల్ చేయండి. ఏజెంట్ కాల్‌ను స్వీకరించి, తనను పరిచయం చేసుకుని, మీ promptను అనుసరిస్తుంది.

కాల్ ముగిసిన తర్వాత దాన్ని పరిశీలించండి:

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"

తదుపరి దశలు