Skip to content

Lesson 5 of 5 · 10 min

Connect your system to the team of brains

Make your app use the Zunous team of brains: hand the model what teammates hold, read memory before answering and report every action your team takes without duplicates.

So far you integrated one brain. But in Zunous brains work as a team: each one knows who handles what, brings what its teammates know and learns from what your people do. In this lesson your system goes from querying one brain to working with the whole team, without your model having to call tools.

What you'll achieve

  • Hand your model the team directory and what teammates hold.
  • Ask for memory in parallel with the search.
  • Report every user action with retries and without duplicates.
  • Tell when to send an activity and when an event.

The team travels in the calls you already make

There are no new endpoints to learn for the basics:

  • GET /instrucciones already includes the section "Tu equipo de brains" when your company has two or more brains.
  • POST /buscar already includes, at the end of contexto, the <conocimiento_de_companeros> block when a teammate knows about the topic, and the del_equipo list in the response.

The only thing to watch is not trimming the instructions or contexto before handing them to the model, and telling it in your system message to say which teammate what it uses comes from.

Search and recall in parallel

js
const BASE = "https://mcp.zunous.com/api/v1/acme/comercial";
const H = { Authorization: `Bearer ${process.env.ZUNOUS_LLAVE}`, "Content-Type": "application/json" };
const post = (ruta, cuerpo) => fetch(BASE + ruta, { method: "POST", headers: H, body: JSON.stringify(cuerpo) }).then((r) => r.json());

export async function contextoPara(pregunta, cliente) {
  const [busqueda, memoria] = await Promise.all([
    post("/buscar", { consulta: pregunta }),
    post("/recordar", { consulta: pregunta, ...(cliente ? { sujeto: cliente } : {}), k: 5 }),
  ]);
  const recuerdos = (memoria.memorias ?? []).map((m) => `- ${m.content}`).join("\n");
  return `${busqueda.contexto}\n\nBrain memory:\n${recuerdos}`;
}

contexto already marks company content as untrusted and teammates' content with their name. Pass it as is: it is information for the model, not instructions.

Report what your team does

Every action by a person that changes data (create, edit, change a stage, log a call) is reported with POST /actividad. Do it from a single place and in the background:

js
const cola = [];

export function reportar(actividad) {
  cola.push({ id: crypto.randomUUID(), ocurrio: new Date().toISOString(), ...actividad });
}

async function vaciar(intento = 0) {
  if (!cola.length) return;
  const lote = cola.splice(0, 50);
  const r = await fetch(BASE + "/actividad", { method: "POST", headers: H, body: JSON.stringify({ sistema: "My CRM", actividades: lote }) }).catch(() => null);
  if (r?.ok || r?.status === 400) return; // a 400 is malformed data: do not retry
  if (intento < 3) setTimeout(() => { cola.unshift(...lote); vaciar(intento + 1); }, 60_000 * 5 ** intento);
}
setInterval(vaciar, 5000);

And in your business code:

js
reportar({ usuario: session.name, accion: "moved the stage to Proposal", objeto: `Opportunity ${op.name}`, contacto: op.email, nombre: op.customer });

The id makes resending duplicate nothing: Zunous answers repetidas instead of storing it again. In production use a durable queue (your cloud's) instead of an in-memory array, and your event's real id instead of a random one.

Activity or event

The activity makes the brain know what happened: it stays in its memory and uses no AI. The event (lesson Send events reliably) makes the brain work: it wakes a skill in Autonomous Mode. For a new lead you can send both.

The full reference is in The team of brains and your system and in REST API.

Practice

  1. Call GET /instrucciones on a brain of a company with two brains and find the team section.
  2. Call POST /buscar with a question from another brain's job and check del_equipo. Repeat with "equipo": false and compare.
  3. Send an activity with id, send it again and confirm repetidas: 1.
  4. Call POST /recordar with the customer's name in sujeto and find the activity.

Check what you learned

1. Your model answers "another brain handles that" but does not bring the fact. What do you check first in your code?

2. POST /actividad answered 429. What do you do?

3. A user opens a customer's record without changing anything. Do you report it?