Conversations
Crear conversación
Crear una nueva conversación programáticamente.
POST
/
api
/
v2
/
conversations
curl -X POST https://app.horneross.com/api/v2/conversations \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"title": "Consulta de producto",
"channel": "api",
"agentId": "ag_xyz789",
"metadata": {
"source": "mi_app",
"userId": "user_123"
},
"initialMessage": "Hola, necesito información sobre precios"
}'
async function createConversation(data) {
const response = await fetch(
'https://app.horneross.com/api/v2/conversations',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
}
);
return response.json();
}
const result = await createConversation({
channel: 'api',
agentId: 'ag_xyz789',
metadata: { source: 'mi_app' },
initialMessage: 'Hola, necesito ayuda'
});
console.log('Conversation created:', result.conversation.id);
import requests
def create_conversation(channel, agent_id=None, title=None, metadata=None, initial_message=None):
data = {'channel': channel}
if agent_id:
data['agentId'] = agent_id
if title:
data['title'] = title
if metadata:
data['metadata'] = metadata
if initial_message:
data['initialMessage'] = initial_message
response = requests.post(
'https://app.horneross.com/api/v2/conversations',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json'
},
json=data
)
return response.json()
result = create_conversation(
channel='api',
agent_id='ag_xyz789',
initial_message='Hola, tengo una consulta'
)
print(f"Created: {result['conversation']['id']}")
{
"conversation": {
"id": "conv_new123",
"title": "Consulta de producto",
"channel": "api",
"status": "UNRESOLVED",
"agentId": "ag_xyz789",
"createdAt": "2024-01-21T16:00:00Z"
}
}
{
"error": "channel_required"
}
{
"error": "conversation_limit_exceeded",
"message": "Has alcanzado el límite de 10 conversación(es) activa(s) para tu plan. Por favor, resuelve o elimina conversaciones existentes, o actualiza tu plan.",
"limit": 10,
"current": 10,
"plan": "level_1"
}
Endpoint
POST /api/v2/conversations
Headers
Bearer token con tu API key de organización.
Siempre
application/jsonRequest Body
Canal de origen. Valores:
api, dashboard, website, agent_builderTítulo descriptivo de la conversación. Si no se proporciona, se genera automáticamente.
ID del agente a vincular con la conversación
Datos personalizados para la conversación
Primer mensaje de la conversación (se crea automáticamente como mensaje del usuario)
curl -X POST https://app.horneross.com/api/v2/conversations \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"title": "Consulta de producto",
"channel": "api",
"agentId": "ag_xyz789",
"metadata": {
"source": "mi_app",
"userId": "user_123"
},
"initialMessage": "Hola, necesito información sobre precios"
}'
async function createConversation(data) {
const response = await fetch(
'https://app.horneross.com/api/v2/conversations',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
}
);
return response.json();
}
const result = await createConversation({
channel: 'api',
agentId: 'ag_xyz789',
metadata: { source: 'mi_app' },
initialMessage: 'Hola, necesito ayuda'
});
console.log('Conversation created:', result.conversation.id);
import requests
def create_conversation(channel, agent_id=None, title=None, metadata=None, initial_message=None):
data = {'channel': channel}
if agent_id:
data['agentId'] = agent_id
if title:
data['title'] = title
if metadata:
data['metadata'] = metadata
if initial_message:
data['initialMessage'] = initial_message
response = requests.post(
'https://app.horneross.com/api/v2/conversations',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json'
},
json=data
)
return response.json()
result = create_conversation(
channel='api',
agent_id='ag_xyz789',
initial_message='Hola, tengo una consulta'
)
print(f"Created: {result['conversation']['id']}")
Response
Conversación creada
Show Propiedades de conversation
Show Propiedades de conversation
ID único de la conversación
Título de la conversación
Canal de origen
Estado inicial:
UNRESOLVEDID del agente asociado
Fecha de creación (ISO 8601)
{
"conversation": {
"id": "conv_new123",
"title": "Consulta de producto",
"channel": "api",
"status": "UNRESOLVED",
"agentId": "ag_xyz789",
"createdAt": "2024-01-21T16:00:00Z"
}
}
{
"error": "channel_required"
}
{
"error": "conversation_limit_exceeded",
"message": "Has alcanzado el límite de 10 conversación(es) activa(s) para tu plan. Por favor, resuelve o elimina conversaciones existentes, o actualiza tu plan.",
"limit": 10,
"current": 10,
"plan": "level_1"
}
Was this page helpful?
⌘I
curl -X POST https://app.horneross.com/api/v2/conversations \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"title": "Consulta de producto",
"channel": "api",
"agentId": "ag_xyz789",
"metadata": {
"source": "mi_app",
"userId": "user_123"
},
"initialMessage": "Hola, necesito información sobre precios"
}'
async function createConversation(data) {
const response = await fetch(
'https://app.horneross.com/api/v2/conversations',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
}
);
return response.json();
}
const result = await createConversation({
channel: 'api',
agentId: 'ag_xyz789',
metadata: { source: 'mi_app' },
initialMessage: 'Hola, necesito ayuda'
});
console.log('Conversation created:', result.conversation.id);
import requests
def create_conversation(channel, agent_id=None, title=None, metadata=None, initial_message=None):
data = {'channel': channel}
if agent_id:
data['agentId'] = agent_id
if title:
data['title'] = title
if metadata:
data['metadata'] = metadata
if initial_message:
data['initialMessage'] = initial_message
response = requests.post(
'https://app.horneross.com/api/v2/conversations',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json'
},
json=data
)
return response.json()
result = create_conversation(
channel='api',
agent_id='ag_xyz789',
initial_message='Hola, tengo una consulta'
)
print(f"Created: {result['conversation']['id']}")
{
"conversation": {
"id": "conv_new123",
"title": "Consulta de producto",
"channel": "api",
"status": "UNRESOLVED",
"agentId": "ag_xyz789",
"createdAt": "2024-01-21T16:00:00Z"
}
}
{
"error": "channel_required"
}
{
"error": "conversation_limit_exceeded",
"message": "Has alcanzado el límite de 10 conversación(es) activa(s) para tu plan. Por favor, resuelve o elimina conversaciones existentes, o actualiza tu plan.",
"limit": 10,
"current": 10,
"plan": "level_1"
}
