איך שולפים שיחות, תמלולים והקלטות דרך API
שלוש בקשות מחזירות את כל מה שקרה בשיחות: הרשימה, שיחה אחת עם התמליל, וקובץ ההקלטה. צריך מפתח API עם ההרשאה calls:read.
איך שולפים רשימת שיחות?
20 השיחות האחרונות שהושלמו
curl 'https://platform.direnium.com/api/v1/calls?status=completed&limit=20' \
-H 'Authorization: Bearer <API-KEY>'| שדה | תיאור |
|---|---|
agentId | רק שיחות של סוכן אחד. |
status | אחד מהערכים: active, completed, failed, no_answer, voicemail. |
direction | אחד מהערכים: inbound, outbound. |
phone | רק שיחות עם מספר מסוים. |
from, to | טווח תאריכים. |
includeTests | לכלול גם שיחות בדיקה. ברירת המחדל: לא. |
limit, offset | דפדוף. ברירת המחדל של limit היא 50, והמקסימום 100. |
התשובה כוללת את calls, מערך של שיחות, ואת total, מספר השיחות שמתאימות לסינון. לכל שיחה יש בין השאר id, status, direction, durationSeconds, summary, sentiment, collectedVariables ו-recordingUrl.
איך שולפים שיחה אחת עם התמליל?
שיחה אחת
curl 'https://platform.direnium.com/api/v1/calls/<CALL-ID>' \
-H 'Authorization: Bearer <API-KEY>'תשובה (מקוצרת)
{
"id": "<CALL-ID>",
"direction": "outbound",
"status": "completed",
"durationSeconds": 142,
"summary": "The customer booked an annual service for Tuesday.",
"sentiment": "positive",
"collectedVariables": [
{ "name": "car_model", "value": "Mazda 3" }
],
"recordingUrl": "https://platform.direnium.com/api/v1/calls/<CALL-ID>/recording",
"transcript": [
{ "role": "agent", "content": "Hi, this is Eve from the garage.", "at": 0 },
{ "role": "user", "content": "Hi, yes.", "at": 3 }
]
}ב-transcript כל שורה היא משפט אחד: role הוא agent, user או system, ו-content הוא הטקסט. שיחה שלא קיימת מחזירה 404.
איך מורידים את ההקלטה?
הורדת ההקלטה לקובץ
curl 'https://platform.direnium.com/api/v1/calls/<CALL-ID>/recording' \
-H 'Authorization: Bearer <API-KEY>' \
-o call.mp3הכתובת ב-recordingUrl היא אותה כתובת, ולכן גם היא דורשת את המפתח. כשאין הקלטה חוזר 404.
ראו גם: איך מפעילים שיחה מיידית דרך API ואיך מקבלים עדכונים ב-Webhooks.