وثائق واجهة برمجة التطبيقات RESTful

قم بدمج تقنية الصوت الذكية القوية لدينا في تطبيقاتك مع الوثائق الشاملة لواجهة برمجة التطبيقات والأمثلة.

البدء

مرحبًا بكم في توثيق واجهة برمجة التطبيقات لوكيل الصوت الذكي. تتيح لك واجهة برمجة التطبيقات الخاصة بنا دمج تفاعلات الصوت المدعومة بالذكاء الاصطناعي في تطبيقاتك.

عنوان القاعدة

https://api.nevoxai.com/v1

المصادقة

جميع طلبات واجهة برمجة التطبيقات تتطلب المصادقة باستخدام مفتاح API في رأس الطلب.

عنوان التوثيق

Authorization: Bearer YOUR_API_KEY

وكلاء الصوت

قم بإنشاء وإدارة وكلاء الصوت الذكي لتطبيقاتك.

إنشاء وكيل صوتي

POST/agents
{
  "name": "Customer Support Agent",
  "language": "en-US",
  "voice_type": "female",
  "personality": "professional",
  "custom_responses": {
    "greeting": "Hello, how can I help you today?",
    "farewell": "Thank you for your time. Have a great day!"
  }
}

معلمات

namestringrequired

Name of the voice agent

languagestring

Language code (default: en-US)

voice_typestring

Voice type (male/female)

استجابة

استجابة النجاح

{
  "agent_id": "agt_123456",
  "name": "Customer Support Agent",
  "status": "active",
  "created_at": "2024-01-01T12:00:00Z"
}

المحادثات

إدارة المحادثات الصوتية بين وكلاء الذكاء الاصطناعي والمستخدمين. تتبع التفاعلات، احصل على نصوص المحادثات، وحلل مقاييس المحادثة.

ابدأ المحادثة

POST/conversations
{
  "agent_id": "agt_123456",
  "user_id": "usr_789012",
  "language": "en-US",
  "initial_context": {
    "customer_name": "John Doe",
    "previous_interaction": "Product Inquiry"
  },
  "settings": {
    "voice_speed": 1.0,
    "voice_pitch": "medium",
    "recording_enabled": true
  }
}

احصل على تاريخ المحادثة

GET/conversations/{conversation_id}

إنهاء المحادثة

POST/conversations/{conversation_id}/end

ويب هوك

قم بإعداد الويب هوكس لتلقي إشعارات في الوقت الحقيقي حول أحداث المحادثة وأنشطة الوكلاء.

إنشاء Webhook

POST/webhooks
{
  "url": "https://your-domain.com/webhook",
  "events": [
    "conversation.started",
    "conversation.ended",
    "message.received",
    "agent.handoff"
  ],
  "secret": "whsec_123456789",
  "description": "Production webhook"
}

أحداث الويب التجريبية

Conversation Started Event

{
  "event": "conversation.started",
  "created_at": "2024-01-01T12:00:00Z",
  "data": {
    "conversation_id": "conv_123456",
    "agent_id": "agt_123456",
    "user_id": "usr_789012"
  }
}

أمان الويبهوك

Signature Verification (Python)

import hmac
import hashlib

def verify_webhook_signature(payload, signature, secret):
    expected = hmac.new(
        secret.encode('utf-8'),
        payload.encode('utf-8'),
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature)

قائمة الأحداث المتاحة

conversation.startedNew conversation initiated
conversation.endedConversation completed
message.receivedNew message in conversation
agent.handoffConversation transferred to human agent
error.occurredError during conversation

التعامل مع الأخطاء

استجابة خطأ

{
  "error": {
    "code": "webhook_error",
    "message": "Failed to deliver webhook",
    "type": "delivery_failure",
    "retry_count": 3,
    "next_retry": "2024-01-01T12:30:00Z"
  }
}