Chat
Envía el mensaje de un cliente y recibe la respuesta del empleado de IA, con el conocimiento y las reglas del negocio aplicados.
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"] ?? "")Parámetros
| Campo | Tipo | Descripción |
|---|---|---|
message | string | Obligatorio. El mensaje del cliente, de 1 a 2000 caracteres. |
conversation_id | string | Opcional. Tu id para este cliente o conversación (letras, dígitos, _ y -, máx. 64). Reutilízalo para mantener el contexto. Si no lo envías, se crea uno nuevo y se devuelve. |
customer_name | string | Opcional. Nombre del cliente, usado por el agente para personalizar las respuestas. |
Respuesta
{
"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"
}Normalmente la respuesta llega en 2 a 5 segundos y la API responde 200 con status: "replied". Si el agente necesita más de 40 segundos, la API responde 202 con status: "pending": lee la respuesta más tarde con GET /v1/conversations/{id} o recíbela por el webhook message.replied.
Mantener la conversación
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?",
},
)Lo que aplica el agente
El mismo motor que WhatsApp y el chat del sitio: perfil del negocio, conocimiento del Brain, productos, reglas del dueño y reglas de seguridad, estilo de los mensajes y límites del plan. Si el dueño pausa la IA o la apaga para los canales web, la API responde 503 agent_unavailable. Las conversaciones creadas por la API aparecen en el panel del dueño como cualquier otro chat.

