See llms.txt for all machine-readable content.

Back to Templates

Reply to grouped WhatsApp messages with Wafly and OpenAI

Quick overview

This workflow receives WhatsApp webhooks from Wafly, groups rapid-fire messages into a single question (and optionally transcribes voice notes), then uses an OpenAI-powered agent with per-contact memory to generate a short reply and sends it back to the user on WhatsApp.

How it works

  1. Receives an incoming WhatsApp event via a webhook endpoint exposed by n8n.
  2. Normalizes the payload so either typed text or a voice-note transcription becomes a single question field.
  3. Filters out non-customer events such as echoes from your own number, group messages, and empty messages.
  4. Sends the customer’s question to an AI agent backed by an OpenAI chat model and a per-phone-number memory window.
  5. Sends the agent’s reply back to the customer as a WhatsApp text message using Wafly.

Setup

  1. Self-host n8n and install the community node n8n-nodes-wafly (this template does not work on n8n Cloud).
  2. Create a Wafly account, connect your number by QR code, and configure Wafly API credentials in n8n. Replace the placeholder Wafly credential references in the Wafly nodes.
  3. Create an OpenAI API credential in n8n and select it in the OpenAI Chat Model node.
  4. Run the manual setup sequence to enable Wafly message buffering (and optionally voice-note transcription by pasting your OpenAI key into Wafly’s transcription settings).
  5. Copy the webhook Production URL from the webhook trigger and register it as the Wafly “received” webhook URL for your instance (using the provided curl request and your instance/token values). See the Wafly API documentation for API and webhook details.

Requirements

  • Self-hosted n8n. This template uses a community node and does not run on n8n Cloud.

Customization

  • Edit the AI Agent system message, tune the 8s silence window and 30s ceiling in the buffer setup node, or swap the memory node for a database.

Additional info

Current setup notes (2 November 2026): The verified Wafly node can be installed from the n8n Cloud canvas by an Owner/Admin. On current node versions, Webhook → Set Webhook configures the Production URL from n8n’s native Webhook trigger. See the current installation and webhook guide (Portuguese). The downloadable JSON contains older setup notes. The complete workflow remains unvalidated on n8n Cloud; configuration success does not confirm callback delivery.

Setup links

Wafly uses a non-official WhatsApp connection via QR code, not the Meta WhatsApp Cloud API. This workflow requires self-hosted n8n and the community node n8n-nodes-wafly; it is not compatible with n8n Cloud. OpenAI API usage is billed separately by OpenAI. Test with your own number before enabling customer replies, and do not use it for unsolicited bulk messages.

Already have an inbound Evolution or Z-API flow? Before adapting it to this buffered-reply workflow, compare individual-text fields in the local webhook compatibility kit (Portuguese). It uses fictitious samples and runs locally without credentials or message sending (13 samples, 93 checks). Buffer timing, audio/transcription, session migration and this workflow’s execution, including n8n Cloud, require separate validation. Maintained by Wafly; Flex is paid and non-official, with WhatsApp restriction risks. If the mapping fits, the guide links to the existing trial for a separate test number.