ORYKSAORYKSADéveloppeurs
Obtenir des clés API

Chat

Envoyez un message client et obtenez la réponse de l'employé IA, avec les connaissances et règles métier appliquées.

POST/v1/chat
curl https://api.oryksa.com/v1/chat \
  -H "Authorization: Bearer oryk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "Hi! What are your opening hours?"}'
const res = await fetch("https://api.oryksa.com/v1/chat", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.ORYKSA_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ message: "Hi! What are your opening hours?" }),
});
const data = await res.json();
console.log(data.reply, data.conversation_id);
import os, requests

r = requests.post(
    "https://api.oryksa.com/v1/chat",
    headers={"Authorization": f"Bearer {os.environ['ORYKSA_API_KEY']}"},
    json={"message": "Hi! What are your opening hours?"},
    timeout=60,
)
data = r.json()
print(data["reply"], data["conversation_id"])
<?php
$ch = curl_init("https://api.oryksa.com/v1/chat");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("ORYKSA_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode(["message" => "Hi! What are your opening hours?"]),
]);
$data = json_decode(curl_exec($ch), true);
echo $data["reply"];
import 'dart:convert';
import 'package:http/http.dart' as http;

final res = await http.post(
  Uri.parse('https://api.oryksa.com/v1/chat'),
  headers: {
    'Authorization': 'Bearer $oryksaApiKey',
    'Content-Type': 'application/json',
  },
  body: jsonEncode({'message': 'Hi! What are your opening hours?'}),
);
final data = jsonDecode(res.body);
print(data['reply']);
val body = JSONObject(mapOf("message" to "Hi! What are your opening hours?")).toString()
val req = Request.Builder()
    .url("https://api.oryksa.com/v1/chat")
    .header("Authorization", "Bearer $oryksaApiKey")
    .post(body.toRequestBody("application/json".toMediaType()))
    .build()
OkHttpClient().newCall(req).execute().use { res ->
    val data = JSONObject(res.body!!.string())
    println(data.getString("reply"))
}
var req = URLRequest(url: URL(string: "https://api.oryksa.com/v1/chat")!)
req.httpMethod = "POST"
req.setValue("Bearer \(oryksaApiKey)", forHTTPHeaderField: "Authorization")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = try JSONSerialization.data(withJSONObject: ["message": "Hi! What are your opening hours?"])
let (data, _) = try await URLSession.shared.data(for: req)
let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
print(json["reply"] ?? "")

Paramètres

ChampTypeDescription
messagestringObligatoire. Le message du client, de 1 à 2000 caractères.
conversation_idstringOptionnel. Votre identifiant pour ce client ou fil (lettres, chiffres, _ et -, max 64). Réutilisez-le pour garder le contexte. Si omis, un nouvel identifiant est créé et renvoyé.
customer_namestringOptionnel. Nom du client, utilisé par l'agent pour personnaliser les réponses.

Réponse

{
  "object": "chat_reply",
  "conversation_id": "a073e8dba25845fe9153840e8bc787c8",
  "status": "replied",
  "reply": "We are open Monday to Friday, 9am to 7pm. Would you like to book a visit?"
}
{
  "object": "chat_reply",
  "conversation_id": "a073e8dba25845fe9153840e8bc787c8",
  "status": "pending",
  "reply": null,
  "hint": "The reply is still being generated. Read it with GET /v1/conversations/a073e8dba25845fe9153840e8bc787c8"
}

En général, la réponse arrive en 2 à 5 secondes et l'API répond 200 avec status: "replied". Si l'agent a besoin de plus de 40 secondes, l'API répond 202 avec status: "pending": lisez la réponse plus tard avec GET /v1/conversations/{id} ou recevez-la via le message.replied webhook.

Maintenir la conversation

curl https://api.oryksa.com/v1/chat \
  -H "Authorization: Bearer oryk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversation_id": "customer-4812",
    "customer_name": "Ana",
    "message": "Can I book for Saturday at 10am?"
  }'
await fetch("https://api.oryksa.com/v1/chat", {
  method: "POST",
  headers: { Authorization: "Bearer " + key, "Content-Type": "application/json" },
  body: JSON.stringify({
    conversation_id: "customer-4812",   // your own id for this customer
    customer_name: "Ana",
    message: "Can I book for Saturday at 10am?",
  }),
});
requests.post(
    "https://api.oryksa.com/v1/chat",
    headers={"Authorization": f"Bearer {key}"},
    json={
        "conversation_id": "customer-4812",  # your own id for this customer
        "customer_name": "Ana",
        "message": "Can I book for Saturday at 10am?",
    },
)

Ce que l'agent applique

Le même moteur que WhatsApp et le chat du site web : profil entreprise, connaissances Brain, produits, règles du propriétaire et garde-fous de sécurité, style de message et limites du forfait. Si le propriétaire met l'IA en pause ou la désactive pour les canaux web, l'API répond 503 agent_unavailable. Les conversations créées via l'API apparaissent dans le tableau de bord du propriétaire comme tout autre chat.