Work at Soy Agentia

AI-powered WhatsApp automation on n8n

Technical design and implementation of a conversational automation workflow for WhatsApp: it orchestrates incoming events, multimodal processing, the conversation with an AI agent that keeps per-session memory, the backend integrations and controlled business actions.

Where
Soy Agentia
Published as
Anonymized technical case
Repository
picojohn/ai-whatsapp-automation

The problem

A WhatsApp operation mixes different message formats, the conversation's context, business actions and moments when the automation has to stop.

Incoming events have to be coordinated, multimodal input normalized and context preserved, only approved operations invoked, and no reply sent at the wrong moment.

The solution

n8n is the orchestration layer between WhatsApp/Meta, OpenAI, the conversational memory and the business APIs: it coordinates message routing, transformations, waits and external calls.

Incoming events are classified and normalized before they reach the AI agent. The agent is connected to an OpenAI language model, to per-session conversational memory in PostgreSQL and to controlled HTTP tools for business operations, instead of having free access to the backend.

Its output is cleaned and transformed before the WhatsApp sending path. When a conversation should not continue as an automated reply, there is a human assistance path.

Message types

Text
Goes into the conversation with the agent.
Audio
Downloaded from the messaging platform, transcribed with OpenAI, logged in the backend and added to the conversation.
Image
Downloaded, uploaded to the backend, analyzed with OpenAI and added to the conversation as a stored description.
PDF
Its size is checked before it is downloaded and uploaded to the backend; files over the limit take a separate path.
Buttons
Button replies are transformed before they enter the conversation.

State controls

  • Pause, AI lock for the lead and user status: they decide whether the automation continues, waits or is redirected.
  • Debounce with a wait and a check of the last message or batch, so that it does not reply twice, late or out of turn when messages arrive in a row.
  • Loop detection.
  • Separate paths for calls and echo events.

Anonymized case: the public repository presents only the conceptual architecture. It does not include the workflow, the internal configuration, prompts, endpoints, credentials or customer data.

Architecture diagram: WhatsApp / Meta sends events to a webhook; the n8n orchestration evaluates the state controls and routes the message to processing and validation, with a multimedia branch for audio, images or PDFs; the AI agent, connected to OpenAI and to conversational memory in PostgreSQL, runs controlled business actions or hands off to human assistance, and the reply goes out through WhatsApp.
Conceptual, anonymized architecture, taken from the public repository.

Built with

  • n8n
  • OpenAI
  • WhatsApp Business API / Meta Graph API
  • PostgreSQL