n8n WhatsApp API template with AI agent and memory
Complete n8n workflow to integrate WhatsApp with AI: receives messages, filters yours (anti-loop), passes the context to the agent and replies automatically with conversation memory. You only need your waseller Session ID and an OpenAI API Key.
What this n8n WhatsApp workflow includes
The JSON covers the complete flow from when a message arrives to when the agent replies. Battle-tested in production with real waseller accounts.
Anti-loop filter
Checks fromMe === true before processing. If the message was sent by you or the bot, the flow stops there. Prevents infinite loops in your n8n flows.
AI agent with memory
Conversation history is retrieved per phone number. The model receives the full context: it knows what was discussed before and replies consistently.
Pre-configured webhook
The Webhook node is already set up to receive WaSender events. Just paste the URL in your waseller number and start receiving messages.
Nodes ready to extend
Add branches for message types (audio, image, document), your own business conditions or calls to your CRM without rewriting the base flow.
How the WhatsApp + n8n integration works
The data flow follows a simple path: WaSender detects the incoming message and forwards it to your n8n webhook. From there, n8n does the rest.
- 1
WaSender sends the event to the n8n webhook
Every message that arrives at your number triggers an HTTP POST to the configured webhook. The payload includes the contact number, the text, the timestamp and the fromMe field.
- 2
The anti-loop filter evaluates fromMe
If fromMe is true, the workflow stops. If it is false (a message from an external contact), it continues to the next node.
- 3
The contact's history is retrieved
The workflow queries the stored history using the phone number as key. This gives the AI memory: it knows what was discussed before.
- 4
The AI agent generates the response
The history + the new message are sent to the model (OpenAI gpt-4.1-mini or higher). The agent replies based on the context and the system instructions you configure.
- 5
The response is sent via WhatsApp
An HTTP node calls the waseller API with the contact number and the generated text. The message appears in the contact's WhatsApp in seconds.
Who is this n8n WhatsApp template for?
Designed for people who already use n8n (or want to start) and need to connect WhatsApp with AI without building the infrastructure from scratch.
Automation freelancers
Deploy WhatsApp + AI solutions for clients in hours, not days.
n8n agencies
Reuse the workflow as a base for chatbot projects. Customize the system prompt per client.
Technical businesses
You have n8n in-house and want a WhatsApp number with API without paying per conversation.
Receive the n8n template by email
We send you the workflow JSON + step-by-step import guide. No spam.
Sin spam. Puedes cancelar cuando quieras.
Frequently asked questions
Do I need to know how to code to use this n8n WhatsApp template?
No. n8n is a visual tool. You only need to import the JSON, paste your waseller Session ID and your OpenAI API Key. The included guide walks you through every step with screenshots.
What is the anti-loop filter and why does it matter?
The anti-loop filter checks the fromMe field of each message. If it is true (the message was sent by you or the bot), the workflow stops there. Without this filter, the bot would reply to its own messages and generate an infinite loop that drains your OpenAI quota.
Does the workflow work with any WhatsApp number?
Yes, with any number you connect in waseller via QR. It works with personal and business numbers. No official WhatsApp Business API or Meta approval required.
Can I import the workflow from a URL in n8n?
Yes. n8n lets you import workflows from a file or from a URL. We send you the JSON directly to your email so you can import it either way.
Ready to connect your WhatsApp to n8n?
Get your WhatsApp number with API on waseller and have it connected to your n8n workflow in under 10 minutes.
Try free for 3 days