/ Cases / Restaurants / AI agent

A multichannel agent that books, sells and takes payment

It answers WhatsApp, Instagram, web and TikTok around the clock: books tables, sells from the online store, charges with a payment link and hands the conversation to a person when needed.

/ Restaurantes Atitlán/ 2026/ ≈52 tools · a different model for each role

≈52

named tools

≈79 %

conversations with no handoff to a person

24 h

coverage

/ The problem

Five locations and six concepts got messages on four channels. Replies were typed by hand, late, and night messages waited until the next day, when the customer had already booked somewhere else.

/ What we built

  • An agent with tools that work on the real database: it creates the booking, generates the payment link, checks the store and saves the customer.
  • Every tool is validated on the server: if the model says "done" without complete data, the booking simply isn't created.
  • One shared inbox (self-hosted Chatwoot) for the team; when a person replies, the agent goes quiet in that thread.
  • One model per role: a sharp one for tours and events, a fast one for transactions, a cheap one for front desk.
  • An automatic daily summary of what happened, plus a daily template reconciliation with Meta.

/ How it works

  1. 01Message on WhatsApp, IG, web or TikTok
  2. 02The agent understands and picks a tool
  3. 03The server validates and runs it
  4. 04Booking, payment or order created
  5. 05Handed to a person if needed

/ By the numbers

Conversations handled by the agent, by channel

■ Real production data · counts per month, no amounts or personal data · November through the 27th. Excludes the API channel (internal tests).

/ Real code

src/lib/agents/shared/human-presence.tsts
export const HUMANO_ATENDIENDO_MS = 24 * 60 * 60 * 1000;

/**
 * ¿Este mensaje lo escribió una PERSONA del equipo hablándole al cliente?
 *
 * `message_type === 1` (outgoing) + `sender.type === 'user'`. El bot postea
 * siempre con el token del agent bot (client.ts postMessage) → sale como
 * `agent_bot`. Las notas privadas NO cuentan: una nota interna no es atender.
 */
export function esMensajeDeHumano(m: MensajeCrudo): boolean {
  return !m.private && m.message_type === 1 && m.sender?.type === 'user';
}

// …
export function humanoAtendiendo(input: {
  lastHumanAgentAt: number | null;
  botRetomaAt?: number | null;
  /** Marcador de `/humano` (epoch ms): cuenta como un mensaje de persona. */
  humanoTomaAt?: number | null;
  now?: number;
}): boolean {
  const lastHumanAgentAt = Math.max(input.lastHumanAgentAt ?? 0, input.humanoTomaAt ?? 0) || null;
  if (!lastHumanAgentAt) return false;
  const now = input.now ?? Date.now();
  if (now - lastHumanAgentAt >= HUMANO_ATENDIENDO_MS) return false;
  const retoma = input.botRetomaAt ?? 0;
  return !(retoma > lastHumanAgentAt);
}

■ The bot stays quiet for 24 h once a team member writes to the customer; the signal is the human message, not the assignment, and /bot hands it back early.

/ Stack

Cloudflare WorkersDurable ObjectsChatwootpgvector (RAG)ClaudeDeepSeekWhatsApp Cloud API