Tasks
Crear task
Crear una nueva tarea automática para un agente.
POST
/
api
/
tasks
curl -X POST https://app.horneross.com/api/tasks \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"prompt": "Genera un resumen de las conversaciones de ayer y envialo por email",
"config": {
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
}
}'
const response = await fetch('https://app.horneross.com/api/tasks', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
agentId: 'agent_abc123',
type: 'schedule',
name: 'Resumen diario',
prompt: 'Genera un resumen de las conversaciones de ayer',
config: {
cronExpression: '0 9 * * *',
timezone: 'America/Argentina/Buenos_Aires',
},
}),
});
const { trigger } = await response.json();
console.log('Task creada:', trigger.id);
import requests
response = requests.post(
'https://app.horneross.com/api/tasks',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
json={
'agentId': 'agent_abc123',
'type': 'schedule',
'name': 'Resumen diario',
'prompt': 'Genera un resumen de las conversaciones de ayer',
'config': {
'cronExpression': '0 9 * * *',
'timezone': 'America/Argentina/Buenos_Aires'
}
}
)
trigger = response.json()['trigger']
print(f'Task creada: {trigger["id"]}')
{
"trigger": {
"id": "trigger_new123",
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"config": {
"prompt": "Genera un resumen de las conversaciones de ayer",
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
},
"isEnabled": true,
"createdAt": "2024-01-21T16:00:00Z",
"agent": {
"id": "agent_abc123",
"name": "Asistente de Ventas",
"iconUrl": null
}
}
}
{
"error": "A task with this name already exists for this agent. Please choose a different name."
}
{
"error": "Agent not found"
}
Endpoint
POST /api/tasks
Headers
string
required
Bearer token con tu API key. Formato:
Bearer sk_live_xxxstring
required
application/jsonRequest Body
string
required
ID del agente que ejecutará la tarea
string
required
Tipo de trigger. Valores:
schedule, integration_event, webhook, conversation_start, conversation_resolved, lead_captured, form_submittedstring
required
Nombre de la tarea (máx 100 caracteres)
string
Descripción opcional (máx 500 caracteres)
string
required
Instrucciones que el agente ejecutará cuando se active el trigger
object
boolean
default:"true"
Si la tarea debe estar activa al crearla
object
curl -X POST https://app.horneross.com/api/tasks \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"prompt": "Genera un resumen de las conversaciones de ayer y envialo por email",
"config": {
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
}
}'
const response = await fetch('https://app.horneross.com/api/tasks', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
agentId: 'agent_abc123',
type: 'schedule',
name: 'Resumen diario',
prompt: 'Genera un resumen de las conversaciones de ayer',
config: {
cronExpression: '0 9 * * *',
timezone: 'America/Argentina/Buenos_Aires',
},
}),
});
const { trigger } = await response.json();
console.log('Task creada:', trigger.id);
import requests
response = requests.post(
'https://app.horneross.com/api/tasks',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
json={
'agentId': 'agent_abc123',
'type': 'schedule',
'name': 'Resumen diario',
'prompt': 'Genera un resumen de las conversaciones de ayer',
'config': {
'cronExpression': '0 9 * * *',
'timezone': 'America/Argentina/Buenos_Aires'
}
}
)
trigger = response.json()['trigger']
print(f'Task creada: {trigger["id"]}')
Response
object
required
{
"trigger": {
"id": "trigger_new123",
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"config": {
"prompt": "Genera un resumen de las conversaciones de ayer",
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
},
"isEnabled": true,
"createdAt": "2024-01-21T16:00:00Z",
"agent": {
"id": "agent_abc123",
"name": "Asistente de Ventas",
"iconUrl": null
}
}
}
{
"error": "A task with this name already exists for this agent. Please choose a different name."
}
{
"error": "Agent not found"
}
Expresiones Cron
Formato:minuto hora día-del-mes mes día-de-semana
| Expresión | Descripción |
|---|---|
0 9 * * * | Todos los días a las 9:00 AM |
0 9 * * 1-5 | Lunes a Viernes a las 9:00 AM |
0 */2 * * * | Cada 2 horas |
0 9 1 * * | Primer día del mes a las 9:00 AM |
30 14 * * 0 | Domingos a las 2:30 PM |
Was this page helpful?
⌘I
curl -X POST https://app.horneross.com/api/tasks \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"prompt": "Genera un resumen de las conversaciones de ayer y envialo por email",
"config": {
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
}
}'
const response = await fetch('https://app.horneross.com/api/tasks', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
agentId: 'agent_abc123',
type: 'schedule',
name: 'Resumen diario',
prompt: 'Genera un resumen de las conversaciones de ayer',
config: {
cronExpression: '0 9 * * *',
timezone: 'America/Argentina/Buenos_Aires',
},
}),
});
const { trigger } = await response.json();
console.log('Task creada:', trigger.id);
import requests
response = requests.post(
'https://app.horneross.com/api/tasks',
headers={
'Authorization': 'Bearer sk_live_xxx',
'Content-Type': 'application/json',
},
json={
'agentId': 'agent_abc123',
'type': 'schedule',
'name': 'Resumen diario',
'prompt': 'Genera un resumen de las conversaciones de ayer',
'config': {
'cronExpression': '0 9 * * *',
'timezone': 'America/Argentina/Buenos_Aires'
}
}
)
trigger = response.json()['trigger']
print(f'Task creada: {trigger["id"]}')
{
"trigger": {
"id": "trigger_new123",
"agentId": "agent_abc123",
"type": "schedule",
"name": "Resumen diario",
"description": "Genera resumen de conversaciones cada mañana",
"config": {
"prompt": "Genera un resumen de las conversaciones de ayer",
"cronExpression": "0 9 * * *",
"timezone": "America/Argentina/Buenos_Aires"
},
"isEnabled": true,
"createdAt": "2024-01-21T16:00:00Z",
"agent": {
"id": "agent_abc123",
"name": "Asistente de Ventas",
"iconUrl": null
}
}
}
{
"error": "A task with this name already exists for this agent. Please choose a different name."
}
{
"error": "Agent not found"
}
