ਕੁਇੱਕਸਟਾਰਟ (API)

ਇਹ ਗਾਈਡ ਤੁਹਾਨੂੰ ਉਹਨਾਂ ਚਾਰ REST ਕਾਲਾਂ ਰਾਹੀਂ ਲੰਘਾਉਂਦੀ ਹੈ ਜਿਨ੍ਹਾਂ ਦੀ ਮਦਦ ਨਾਲ ਤੁਸੀਂ AI ਏਜੰਟ ਨਾਲ ਆਪਣੀ ਪਹਿਲੀ ਫ਼ੋਨ ਕਾਲ ਦਾ ਜਵਾਬ ਦੇ ਸਕਦੇ ਹੋ।

ਕਦਮ 1: API ਕੁੰਜੀ ਪ੍ਰਾਪਤ ਕਰੋ

  1. ਲੌਗ ਇਨ ਕਰੋ

    app.thunderphone.com ਖੋਲ੍ਹੋ।

  2. ਕੁੰਜੀਆਂ ਤੱਕ ਜਾਓ

    ਡੈਸ਼ਬੋਰਡ ਵਿੱਚ ਸੰਗਠਨ → ਕੁੰਜੀਆਂ 'ਤੇ ਜਾਓ।

  3. ਕੁੰਜੀ ਬਣਾਓ

    ਕੁੰਜੀ ਬਣਾਓ 'ਤੇ ਕਲਿੱਕ ਕਰੋ, ਇਸਨੂੰ ਨਾਮ ਦਿਓ ਅਤੇ sk_live_... ਮੁੱਲ ਕਾਪੀ ਕਰੋ। ਕੱਚੀ ਕੁੰਜੀ ਸਿਰਫ਼ ਇੱਕ ਵਾਰ ਦਿਖਾਈ ਜਾਂਦੀ ਹੈ — ਇਸਨੂੰ ਤੁਰੰਤ ਆਪਣੇ ਗੁਪਤ ਜਾਣਕਾਰੀ ਮੈਨੇਜਰ ਵਿੱਚ ਸਟੋਰ ਕਰੋ।

ਇਸ ਗਾਈਡ ਦੌਰਾਨ, sk_live_YOUR_API_KEY ਨੂੰ ਉਸ ਮੁੱਲ ਨਾਲ ਬਦਲੋ ਜੋ ਤੁਸੀਂ ਹੁਣੇ ਕਾਪੀ ਕੀਤਾ ਹੈ। ਕੁੰਜੀ ਤੁਹਾਡੇ ਸੰਗਠਨ ਦੀ ਆਪਣੇ ਆਪ ਪਛਾਣ ਕਰਦੀ ਹੈ, ਇਸ ਲਈ ਤੁਹਾਨੂੰ ਕਦੇ ਵੀ URLs ਵਿੱਚ ਸੰਗਠਨ 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"

ਅਗਲੇ ਕਦਮ