WhatsApp Automation

AI-assisted WhatsApp support that answers from a knowledge base and hands off to a person when it should.

Discipline
Automation
Status
MVP
WhatsApp support conversation beside the message pipeline: webhook, verification, queue, worker, retrieval, reply and escalation
Reconstruction. The conversation runs in WhatsApp; the pipeline steps map to the real NestJS services.

Overview

A support automation backend on the WhatsApp Cloud API. A customer sends a message and gets an answer grounded in the company's own FAQ knowledge base. When the AI decides a person is needed, it escalates to the support team and marks the conversation.

Role
Backend architecture and engineering
Services
Backend architecture, Messaging automation, AI integration, Queues and workers
Platform
API and background workers

Context

Support questions arrive on WhatsApp at all hours. Many are repeat questions with known answers. Some need a person, quickly.

Challenge

Meta expects the webhook to respond immediately, while an AI reply takes seconds. Answers must come from approved content, not from the model's imagination, and escalation has to be reliable. The webhook is public by necessity, so every request has to be verified.

Strategy

The decisionsthat shaped it.

  1. 01

    Acknowledge now, answer in the background

    Inbound messages are queued in BullMQ on Redis. The webhook returns instantly and a worker writes the reply.

  2. 02

    Grounded answers

    Replies draw on a pgvector knowledge base of approved FAQs, matched with embeddings.

  3. 03

    Escalation is a state

    When a person is needed, the conversation is marked escalated and the support number is pinged on WhatsApp.

Server logs for one escalated WhatsApp conversation, from webhook to agent alert
Server log for one escalated conversation, from webhook to agent alert. Reconstructed from the service names in the codebase.

Experience

The main paths through the product, in the order people take them.

Who does what,in what order.

Customer

  1. Send message
  2. Get a grounded answer
  3. Reach a person if needed

System

  1. Verify signature
  2. Queue message
  3. Retrieve FAQs
  4. Generate reply
  5. Send or escalate
WhatsApp support conversation beside the message pipeline: webhook, verification, queue, worker, retrieval, reply and escalation
Each inbound message is traced through verification, the queue, retrieval and reply.

Interfacedecisions.

  • 01

    The interface is the conversation itself: short answers, a clear handoff, no dead ends.

  • 02

    Admin tools for tickets and meetings are planned on the same data, behind JWT and role guards.

Engineering

Architecture in brief. The stack supports the product, not the other way round.

What powers it.

  1. 01Channel

    • WhatsApp Cloud API
  2. 02Services

    • NestJS
    • BullMQ workers
    • OpenAI
  3. 03Data

    • PostgreSQL
    • pgvector
    • Prisma
  4. 04Infrastructure

    • Redis
    • Docker

Signature verification

Requests must carry Meta's X-Hub-Signature-256 before anything is processed.

Background workers

AI calls never block the webhook. Slow providers delay a reply, not the channel.

Typed data layer

Prisma with an explicit Postgres driver adapter and migrations under version control.

Outcome

Support conversations get an immediate, grounded answer, and the ones that need a person reach one. The backend is structured to grow into tickets and meetings on the same NestJS foundation.