How it works
Architecture, principles and the life of a WhatsApp message inside Wagend.
Principles
- 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.
- The database enforces the rules. Double booking is impossible because PostgreSQL rejects overlapping allocations, not because the app "checks first".
- 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.
- 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
- 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.
- Understood. Voice notes are transcribed. We identify the customer and the conversation. If a person took over, the bot stays silent.
- 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_slotorconfirm_hold. - 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_takenwith alternatives) so the AI asks again. - Exact reply. Dates, times, services, prices and addresses are rendered from templates filled with the real result.
- Events.
booking.confirmedand friends trigger automations (reminders) and your webhooks.
Where to go next
- Bookings and holds explains the guarantees.
- WhatsApp and AI explains what the AI can and cannot do.