Araç Oluştur

Yeni bir araç oluşturun

Endpoint

POST/api/v1/tools

Yeni bir araç oluşturur ve konfigürasyonunu kaydeder.

İstek Parametreleri

namestring (gerekli)

Aracın adı

typestring (gerekli)

Araç tipi: API_REQUEST, DATABASE_QUERY, KNOWLEDGE_BASE, SEND_TEXT, END_CALL, TRANSFER_CALL

descriptionstring (gerekli)

Aracın açıklaması

configobject (gerekli)

Araç tipine özel konfigürasyon

İstek Örnekleri

API Request Aracı

cURL
curl -X POST https://api.wespoke.ai/api/v1/tools \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "CRM Sorgu",
    "type": "API_REQUEST",
    "description": "CRM API'sinden müşteri bilgisi çeker",
    "config": {
      "url": "https://api.crm.local/customers/{id}",
      "method": "GET",
      "headers": {
        "Authorization": "Bearer {{secrets.CRM_API_KEY}}"
      },
      "query": {
        "expand": "details"
      }
    }
  }'

Database Query Aracı

cURL
curl -X POST https://api.wespoke.ai/api/v1/tools \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Müşteri Bilgisi",
    "type": "DATABASE_QUERY",
    "description": "Veritabanından müşteri bilgisi getirir",
    "config": {
      "query": "SELECT * FROM customers WHERE phone = :phone",
      "parameters": {
        "phone": "{{caller_number}}"
      }
    }
  }'

Knowledge Base Aracı

cURL
curl -X POST https://api.wespoke.ai/api/v1/tools \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ürün Bilgisi",
    "type": "KNOWLEDGE_BASE",
    "description": "Bilgi tabanından ürün bilgisi arar",
    "config": {
      "knowledgeBaseId": "kb_xyz789",
      "maxResults": 3
    }
  }'

Yanıt Örneği

201 Created
{
  "success": true,
  "data": {
    "id": "tool_abc123",
    "name": "CRM Sorgu",
    "type": "API_REQUEST",
    "description": "CRM API'sinden müşteri bilgisi çeker",
    "config": {
      "url": "https://api.crm.local/customers/{id}",
      "method": "GET",
      "headers": {
        "Authorization": "Bearer {{secrets.CRM_API_KEY}}"
      },
      "query": {
        "expand": "details"
      }
    },
    "createdAt": "2024-01-14T09:00:00Z",
    "updatedAt": "2024-01-14T09:00:00Z"
  }
}

Hata Yanıtları

400 Bad Request
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Geçersiz araç konfigürasyonu",
    "details": {
      "name": "Araç adı gereklidir",
      "type": "Geçersiz araç tipi"
    }
  }
}