Skip to content

Lesson 6 of 6 · 12 min

Assignments, approvals and the schedule from your system

How to bring into your software the conversation with the brain, assignments with their plan, path and rating, the approvals inbox and the Zunous team schedule, with the REST API.

Your team doesn't need to sign in to Zunous to work with its brains. With the REST API your system can talk to the brain, follow the assignments that come out of that conversation, resolve approvals and show the whole team's week. Everything the Console shows is also available through the API.

What you'll build

  • A chat that hands each message to the brain and shows the assignment when it starts one.
  • An assignment view with its progress, its cost and two buttons to rate it.
  • An approvals inbox.
  • A dashboard with "Needs you" and the team's week.

Every call leaves your server with the brain's key and the zunous(path, body) function from the lesson Your first REST API call: without a body it makes a GET, with a body a POST.

1. One message, one call

js
const r = await zunous("/conversar", {
  usuario: { id: session.userId, nombre: session.name },
  conversacion: thread.id,
  mensaje: text,
  sistema: "MyCRM",
});
show(r.respuesta);                 // Markdown
if (r.encargo) follow(r.encargo.id);

The user's identity comes from your server-side session, never from a field the browser can change. The brain remembers what it discussed with each person and, when they approve a plan, encargo carries its id, its tasks and its delivery date.

2. The assignment: progress, cost and rating

GET /encargos/{id} returns the status (en_cola, en_curso, entregado, incompleto or fallido), each task with its dates and result, the deliverable and recorrido, with what each step cost and the budget at approval. Poll every minute while it's in progress.

When it finishes, show "Was it useful?" and send back the answer:

js
await zunous(`/encargos/${id}/calificacion`, {
  usuario: { id: session.userId },
  calificacion: "falto",
  comentario: "Each company's corporate phone was missing.",
});

Only whoever asked for the assignment can rate it. The comment reaches the next plan as a lesson.

3. The approvals inbox

GET /aprobaciones?estado=pendiente lists what is waiting on a person, with the proposed text and why it's waiting. To resolve one:

js
await zunous(`/aprobaciones/${a.id}`, {
  usuario: { id: session.userId, nombre: session.name },
  decision: "aprobar",
  contenido: correctedText,          // optional
});

On approval, the brain sends the final text and learns from the correction. An approval that's already resolved answers 409.

4. Needs you and the team's week

GET /agenda?desde=2026-11-30 returns the week of the whole team, even though the key belongs to one brain: brains (with their color), bloques (tasks, routines, follow-ups and deliveries), necesita_de_ti (approvals, deliveries to rate and blockers, with veces when it groups several alike), cargados (days when a brain can't fit its tasks) and zona. The range goes up to 31 days. Details in REST API.

Practice

  1. Build the chat from step 1 and ask the brain for a small piece of work. Approve it.
  2. Show the assignment with its tasks and, when it finishes, rate it from your system.
  3. List the pending approvals and approve one with corrected text.
  4. Draw "Needs you" with each brain's color.