WhatsApp Multimodal AI Assistant using GPT-4o and Evolution API - n8n Workflow

Build a robust WhatsApp AI assistant with this advanced n8n workflow. It handles text, audio, images, and documents using GPT-4o, Redis queuing, and PostgreSQL memory. Get started with n8n templates today.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• Users needing advanced, stateful WhatsApp business automation.
• Developers looking for comprehensive n8n templates for AI agents.
• Businesses requiring a reliable WhatsApp bot that handles various media types (text, audio, image).
• Anyone operating an n8n installation requiring Redis and PostgreSQL integration for enhanced functionality.

Overview

Developing a reliable chat assistant often struggles with handling rapid user inputs (message queuing) and complex media types. This sophisticated n8n workflow solves both problems by integrating multiple powerful services. It utilizes the Evolution API for WhatsApp connectivity, Redis for implementing a crucial 10-second message queuing mechanism, and PostgreSQL for persistent chat memory, ensuring long, context-aware conversations.

The core of the system is the AI Agent, powered by the latest GPT-4o model, capable of transcribing audio, analyzing images, extracting information from documents, and generating context-aware responses. Furthermore, the final stage includes a specialized Format Response step, which uses a secondary AI call to ensure that lengthy generated replies are automatically broken down into multiple, naturally delayed, WhatsApp-optimized messages. This high-performance n8n node configuration ensures professionalism and efficiency, making it one of the most powerful n8n templates available for customer engagement.

How it Works

This comprehensive n8n workflow initiates when the Receive WhatsApp n8n trigger receives a webhook from the Evolution API.


  1. Ingestion & Filtering: The initial nodes parse the data, filter against an ALLOWED_NUMBER list, and immediately mark the message as read via the Evolution API n8n node.

  2. Message Routing & Processing: The Route by Message Type n8n node directs the message flow based on its type (text, audio, image, document). Media types are converted from Base64 and processed by dedicated OpenAI n8n nodes (e.g., audio is transcribed via Whisper, images and documents are analyzed using GPT-4o Vision). The content is then unified into a single input format.

  3. Queuing: The input is pushed onto a Redis list (Queue Message) using the recipient's JID as the key. A 10-second pause (Wait for More Messages) allows for message batching. The flow proceeds only if the current message is the final item received within that window, preventing the AI from responding prematurely to fragmented user input.

  4. AI Generation: The concatenated input is fed into the AI Agent n8n node, which maintains conversation state using the Postgres Chat Memory n8n node and generates a response using GPT-4o-mini.

  5. Response Formatting: The raw AI output enters a specialized chain which uses another call to GPT-4o-mini to convert the response into a structured JSON array of short, separate messages, optimized for WhatsApp readability.

  6. Sending: The Split Messages n8n node iterates over the response array. Messages are sent sequentially using the Evolution API n8n node, with a message-length-dependent delay applied to simulate natural typing speed. Finally, the Redis queue is cleared using a Redis n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these setup steps:


  1. Import: Copy the provided JSON and import it into your n8n instance as a new workflow.

  2. Community Node: Install the Evolution API community n8n node if you haven't already: n8n-nodes-evolution-api.

  3. Credentials: Configure the required credentials for this n8n template:

Evolution API (Server URL and API key).
OpenAI API.
Redis connection (for queuing).
PostgreSQL connection (for chat memory, ensuring the whatsappchatmemory table exists).

  1. Webhook Setup: Activate the Receive WhatsApp n8n trigger. Copy the generated webhook URL.

  2. Evolution API Configuration: In your Evolution API settings, set the copied n8n webhook URL as the target for the MESSAGESUPSERT event.

  3. Customization: Replace the YOUR[email protected] placeholder in the Filter Allowed Numbers n8n node with the number(s) you wish to allow to interact with the bot.

Node Details

Receive WhatsApp (Webhook n8n trigger): Serves as the primary entry point, listening for incoming WhatsApp messages from the Evolution API on the specified path whatsapp-multimodal.
Evolution API n8n node (Mark as Read): Immediately interacts with the WhatsApp chat API to mark the incoming message as viewed, enhancing user experience.
Route by Message Type (Switch n8n node): Determines the type of message (conversation, audioMessage, imageMessage, documentMessage) and routes the flow accordingly for specialized processing.
OpenAI n8n node (Transcribe Audio): Uses the Whisper model to transcribe voice messages into text, integrating multimodal capability into the n8n workflow.
OpenAI n8n node (Analyze Image/Document): Utilizes GPT-4o Vision to analyze the content of image and document files attached to the message, converting visual data into descriptive text for the AI.
Redis n8n node (Queue Message / Get Queued Messages): Manages concurrent messages by temporarily storing input based on the remoteJid, acting as a crucial flow control mechanism in this n8n workflow.
If n8n node (Is Last Message?): Checks if the currently processing message is the last one received within the defined 10-second queue window, ensuring the bot responds only when the user's thought process is complete.
AI Agent n8n node: The core intelligence node. It orchestrates the LLM (gpt-4o-mini) and leverages the Postgres Chat Memory n8n node to maintain long-term conversational context.
Chain LLM n8n node (Format Response): This specialized n8n node uses a system prompt and a structured output parser to automatically segment long AI responses into WhatsApp-friendly message chunks.
Evolution API n8n node (Send Text): Sends the final, segmented responses back to the user, incorporating a dynamic delay parameter in the n8n node configuration for realistic typing simulation.

Related n8n Workflows

Free

Nodes: 20 Nodes
Updated: December 26 2025
View all
Created by
Antonio Gasso
Antonio Gasso

Featured*