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
- Receives an incoming WhatsApp event via a webhook endpoint exposed by n8n.
- Normalizes the payload so either typed text or a voice-note transcription becomes a single
question field.
- Filters out non-customer events such as echoes from your own number, group messages, and empty messages.
- Sends the customer’s question to an AI agent backed by an OpenAI chat model and a per-phone-number memory window.
- Sends the agent’s reply back to the customer as a WhatsApp text message using Wafly.
Setup
- Self-host n8n and install the community node
n8n-nodes-wafly (this template does not work on n8n Cloud).
- Create Wafly API credentials in n8n and replace the placeholder Wafly credential references in the Wafly nodes.
- Create an OpenAI API credential in n8n and select it in the OpenAI Chat Model node.
- 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).
- 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).
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.