ક્વિકસ્ટાર્ટ (API)
આ માર્ગદર્શિકા તમને AI એજન્ટ સાથે તમારો પહેલો ફોન કૉલ જવાબ આપવા માટે જરૂરી ચાર REST કૉલ્સમાંથી પસાર કરાવે છે.
પગલું 1: API કી મેળવો
- લૉગ ઇન કરો
app.thunderphone.com ખોલો.
- કીઝ પર જાઓ
ડેશબોર્ડમાં સંસ્થા → કીઝ પર જાઓ.
- કી બનાવો
કી બનાવો પર ક્લિક કરો, તેને નામ આપો અને
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"