How to Set Up E-commerce WhatsApp: AI Sales Assistant and Cart Recovery in n8n
Abandoned carts cost e-commerce businesses an estimated $18 billion annually. The window to recover a sale is narrow — studies show 40% of cart abandoners can be recovered within the first hour, but o
Abandoned carts cost e-commerce businesses an estimated $18 billion annually. The window to recover a sale is narrow — studies show 40% of cart abandoners can be recovered within the first hour, but only if you reach them with the right message on the right channel. Email recovery sequences convert at 5-8%. WhatsApp, when done right, converts at 15-30%. The difference is not the channel alone — it's the ability to answer questions in real time and keep the conversation moving toward checkout. This guide shows you how to build that system in n8n using GPT-4o and the WhatsApp Business API.
Why Cart Recovery Fails on Email and Succeeds on WhatsApp
The core problem with email recovery is latency and passivity. You send a message, the customer sees it hours later, and if they have a question about sizing, shipping, or compatibility, they have no way to get an answer immediately. They close the tab and the sale is gone.
WhatsApp changes the equation in three ways. First, open rates on WhatsApp Business messages average 85-98%, versus 20-25% for email. Second, the channel is conversational by design — customers expect to reply and get a response. Third, when you back that conversation with a GPT-4o assistant that has full knowledge of your product catalog, you can resolve objections in seconds instead of hours.
The workflow described here handles the full recovery cycle: detects abandonment from your e-commerce platform, waits a configurable cooldown period, sends a personalized outreach message, listens for replies, routes product questions to GPT-4o for instant answers, and escalates to a human agent when the conversation hits a decision point that requires it. The system is stateless between sessions but maintains conversation history in memory for the duration of each interaction.
What You Need Before You Start
Before opening n8n, gather the following credentials and services. Skipping this step is the most common reason implementations stall.
WhatsApp Business API access: You need an approved WhatsApp Business Account through Meta's Business Manager. The fastest path is through a BSP (Business Solution Provider) like 360dialog, Twilio, or WATI. Each gives you an API key and a webhook URL for incoming messages. If you already use Go High Level or a similar CRM with WhatsApp integration, check whether it exposes webhook events — some do, which eliminates the need for a direct BSP.
OpenAI API key with GPT-4o access: Standard API key from platform.openai.com. Budget approximately $0.002-0.006 per conversation for the volumes a typical recovery workflow generates.
Abandoned cart webhook from your e-commerce platform: Shopify, WooCommerce, and most major platforms can send a webhook payload when a cart is abandoned. In Shopify, this is the checkouts/create or checkouts/update webhook. In WooCommerce, use the built-in webhook manager or a plugin like WooCommerce Abandoned Cart Pro. The payload needs to include: customer phone number, customer name, cart items (name, price, quantity), and a link back to the checkout.
n8n instance: Self-hosted on your VPS or n8n Cloud. The workflow uses standard nodes available in all n8n versions 0.200 and above.
Step-by-Step: Building the Workflow in n8n
Step 1 — Webhook trigger for cart abandonment. Add a Webhook node as the trigger. Set the HTTP method to POST and generate the URL. Paste this URL into your e-commerce platform's abandoned cart webhook settings. In the webhook node, enable "Respond immediately" so your platform doesn't timeout waiting for a response. The node will receive the cart payload and pass it downstream.
Step 2 — Wait node for cooldown. Add a Wait node after the trigger. Configure it for 30-60 minutes. This is critical: sending a recovery message immediately after abandonment feels intrusive and often converts worse than waiting. The 30-60 minute window catches customers who are still in a buying mindset but got interrupted.
Step 3 — Check if the order was already placed. Before sending any message, you need to verify the customer didn't complete the purchase during the cooldown. Add an HTTP Request node that queries your e-commerce platform's Orders API using the customer's email or phone number. Add an IF node to check whether the order exists — if it does, stop the workflow with a No Operation node. If it doesn't, continue.
Step 4 — Send the initial WhatsApp recovery message. Add an HTTP Request node configured to call your WhatsApp BSP's API. Set the method to POST and the URL to your BSP's message endpoint. In the body, use n8n expressions to inject the customer's name and cart items dynamically:
{
"to": "{{ $json.customer.phone }}",
"type": "text",
"text": {
"body": "Hi {{ $json.customer.first_name }}, you left something behind! Your {{ $json.line_items[0].title }} is waiting in your cart. Need help completing your order or have questions? Reply here and I'll help right now. 👉 {{ $json.abandoned_checkout_url }}"
}
}
Step 5 — Incoming message webhook and routing. Add a second Webhook node to receive replies from customers. Register this URL with your BSP as the inbound message webhook. When a message arrives, extract the sender's phone number and message body. Use a Switch node to route based on keywords: if the message contains "human", "agent", or "help", route to the escalation path. Otherwise, route to the GPT-4o assistant path.
Step 6 — GPT-4o assistant for product questions. Add an OpenAI node (or HTTP Request node hitting the chat completions endpoint). Set the model to gpt-4o. In the system prompt, inject your product catalog, shipping policies, and return policy. Keep the system prompt under 2000 tokens for latency. Pass the customer's message as the user message. Store conversation history in n8n's Redis node or a simple JSON object keyed by phone number, and append it to each subsequent API call to maintain context.
Step 7 — Send the assistant's reply via WhatsApp. Take the response from GPT-4o and send it back through the same WhatsApp HTTP Request node structure from Step 4. Loop this step back to the incoming message webhook for subsequent replies.
Step 8 — Escalation to human agent. When the Switch node routes to escalation, send a WhatsApp message informing the customer that a human will follow up within X minutes. Simultaneously, notify your support team via Slack (use the Slack node), email (use the Gmail or SMTP node), or directly in your helpdesk. Include the full conversation history in the escalation notification so the agent has context.
Configuration Details That Determine Performance
The system prompt for GPT-4o is the highest-leverage element in the entire workflow. A weak prompt produces generic responses that don't close sales. A strong prompt includes: your brand voice guidelines, the specific product the customer was viewing (injected dynamically from the cart payload), known objections for that product category, your return policy verbatim, and an explicit instruction to guide the conversation toward checkout when the customer's objection has been addressed.
An example closing instruction in the system prompt: "When you have answered the customer's question and they appear satisfied, provide the checkout link one more time with a clear action: 'Your cart is still saved — you can complete your purchase here: [CHECKOUT_URL]'. Do not ask open-ended questions after resolving an objection."
For conversation memory, the simplest n8n implementation stores chat history in a Function node using static data (available in n8n via $getWorkflowStaticData('global')). Key the object by phone number and clear the history 24 hours after the last message. For higher volumes, use a Redis node or a simple Postgres table.
Set a maximum conversation depth of 8-10 exchanges before auto-escalating. Long AI conversations with undecided customers rarely convert and cost in API tokens — hand them to a human who can use judgment.
Common Pitfalls and How to Avoid Them
Sending without opt-in verification. WhatsApp Business API requires that customers have opted in to receive messages from your business. If your checkout flow doesn't collect explicit WhatsApp consent, you risk your Business Account being flagged or suspended. Add an opt-in checkbox to your checkout and store consent in your customer database. Filter the webhook trigger to only proceed when consent is confirmed.
Not handling the "already purchased" check. This is the second most common issue. If the cooldown period passes and you don't verify order status, you'll message customers who completed their purchase, which damages trust and increases opt-out rates. The HTTP Request check against your Orders API in Step 3 is not optional.
GPT-4o hallucinating product details. If your system prompt injects product information from a static string rather than the live cart payload, the assistant may describe a product incorrectly. Always inject the product name, SKU, price, and key specs directly from the $json object in the trigger payload. Don't rely on GPT-4o's training data to know your products.
No rate limiting on outbound messages. WhatsApp Business API has per-number messaging limits that scale with your tier. If you're on Tier 1 (1,000 unique contacts per 24 hours), sending recovery messages in bulk will hit the ceiling. Use n8n's Wait node between messages or process the webhook queue through a RabbitMQ or Redis queue to control throughput.
Escalation with no context. If your human agent escalation notification contains only the customer's phone number and not the conversation history, agents will ask customers to repeat themselves — which kills the recovery. Always pass the full message history in the escalation payload. If you're escalating to a helpdesk like Intercom or Zendesk, use their API to create a ticket with the conversation pre-populated.
Expected Results and How to Measure Them
A well-configured WhatsApp recovery workflow should generate a 15-30% recovery rate on abandoned carts where the customer has provided a WhatsApp-registered phone number and consent. Compare this against your baseline email recovery rate in your analytics platform of choice.
Track four metrics in your n8n execution logs and your e-commerce platform: (1) messages sent versus orders recovered, (2) average conversation length before purchase or escalation, (3) escalation rate as a percentage of total conversations — target under 20%, (4) opt-out rate per 1,000 messages — keep this under 2% or WhatsApp will flag your account.
If recovery rate is below 10%, audit the first message — it's usually either too sales-forward or missing the checkout link. If escalation rate is above 30%, your GPT-4o system prompt is not handling common objections and needs to be expanded with your actual support team's FAQ data. If opt-out rate is high, the cooldown window may be too short or the initial message tone is off.
The workflow scales linearly with volume. At 1,000 abandoned carts per month and a 20% recovery rate, you're recovering 200 orders per month with marginal operational cost — no additional headcount, no per-recovery fee, just API usage that typically runs under $50/month at that scale.
Ja construimos isso pra voce
Nao comece do zero. O SEO Content Machine — Keyword to Published Article in Under 5 Minutes e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.
Instalar por $59 →