How it works

Architecture, principles and the life of a WhatsApp message inside Wagend.

Principles

  1. Deterministic core, AI as interpreter. The AI understands the customer and calls tools. The engine computes availability, holds, confirms and charges. The AI never invents a time or a price.
  2. The database enforces the rules. Double booking is impossible because PostgreSQL rejects overlapping allocations, not because the app "checks first".
  3. API-first. The dashboard, the booking page, the WhatsApp bot and MCP all use the same services. If something can't be done through the API, it's missing from the API.
  4. The credential defines the tenant. A key or session always belongs to one workspace.

Architecture

Channels:   WhatsApp · Booking page · Dashboard · REST / MCP
                 │
Gateway:    credential → workspace · scopes · rate limits · signed webhooks
                 │
Core:       conversations + AI │ scheduling engine │ automations │ payments │ knowledge
                 │
Data:       PostgreSQL (row-level security, exclusion constraints, jobs) · Redis
External:   AI models (OpenRouter) · speech-to-text · WhatsApp provider · Pix

The life of a message

  1. Arrives. The WhatsApp provider calls our webhook. We verify the HMAC signature, drop duplicates by message id and store it. We answer in under 200 ms.
  2. Understood. Voice notes are transcribed. We identify the customer and the conversation. If a person took over, the bot stays silent.
  3. The AI asks. The model gets the business context, the local date and time, a structured conversation state and the last messages. It can only call tools such as find_slots, hold_slot or confirm_hold.
  4. The engine decides. Each tool call is validated against a strict schema and business rules, then executed. Errors come back as structured data (for example slot_taken with alternatives) so the AI asks again.
  5. Exact reply. Dates, times, services, prices and addresses are rendered from templates filled with the real result.
  6. Events. booking.confirmed and friends trigger automations (reminders) and your webhooks.

Where to go next