ദ്രുതാരംഭം (API)

ഈ ഗൈഡ് ഒരു AI ഏജന്റ് ഉപയോഗിച്ച് നിങ്ങളുടെ ആദ്യ ഫോൺ കോൾ കൈകാര്യം ചെയ്യാൻ ആവശ്യമായ നാല് REST കോളുകളിലൂടെ നിങ്ങളെ നയിക്കുന്നു.

ഘട്ടം 1: ഒരു API കീ നേടുക

  1. ലോഗിൻ ചെയ്യുക

    app.thunderphone.com തുറക്കുക.

  2. കീകളിലേക്ക് പോകുക

    ഡാഷ്ബോർഡിൽ Organization → Keys എന്നതിലേക്ക് പോകുക.

  3. ഒരു കീ സൃഷ്ടിക്കുക

    Create key ക്ലിക്ക് ചെയ്യുക, അതിന് ഒരു പേര് നൽകുക, തുടർന്ന് sk_live_... മൂല്യം പകർത്തുക. അസംസ്കൃത കീ ഒരിക്കൽ മാത്രം കാണിക്കും — അത് ഉടൻ തന്നെ നിങ്ങളുടെ സീക്രട്ട് മാനേജറിൽ സൂക്ഷിക്കുക.

ഈ ഗൈഡിലുടനീളം, sk_live_YOUR_API_KEY എന്നത് നിങ്ങൾ ഇപ്പോൾ പകർത്തിയ മൂല്യം ഉപയോഗിച്ച് മാറ്റിസ്ഥാപിക്കുക. കീ നിങ്ങളുടെ ഓർഗനൈസേഷനെ സ്വയമേവ തിരിച്ചറിയുന്നതിനാൽ, URL-കളിൽ ഒരിക്കലും org 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"

അടുത്ത ഘട്ടങ്ങൾ