Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Implementing n8n WhatsApp Business API automation with RAG for Accurate Replies

Description and use

Automation recipe for WhatsApp replies using n8n, Meta Business Manager, and LLM with RAG, ensuring accurate, secure, and up‑to‑date responses.

Problem

Automating WhatsApp Business API replies while ensuring answers are grounded in verified documentation and preventing hallucinations.

Outcome

The recipe enables fully automated, accurate WhatsApp replies by combining n8n orchestration, Meta Business API, an LLM with RAG, and a vector store, while handling security, rate limits, and index freshness.

Workflow

  • Configure infrastructure: deploy n8n, set up Meta Business Account, obtain WhatsApp Business API token.
  • Create webhook trigger in n8n and configure Meta webhook subscription.
  • Parse incoming messages with a Code node to extract sender_id and message_text.
  • Retrieve relevant FAQ chunks from a vector store (Pinecone/Supabase) using the message_text as query.
  • Construct LLM prompt with retrieved context and a strict system prompt to avoid hallucinations.
  • Generate reply via LLM node (e.g., GPT‑4o).
  • Truncate reply if >4000 characters and map to WhatsApp node to send response.
  • Deploy and test: monitor logs, ensure latency <5s, adjust context size or model if needed.
  • Add security: verify X‑Hub‑Signature‑256 header with a Function node.
  • Add rate‑limit handling with a Throttle node and daily quota counter.
  • Schedule nightly index refresh to keep vector store in sync with updated FAQ docs.

Evidence

To automate WhatsApp Business API replies using n8n and RAG, you must integrate an LLM node with a vector database reference.

Source

Add a Function node right after the HTTP Trigger that reads x-hub-signature-256 and throws an error if the values differ.

Source

After the RAG Retrieval step, insert a Set node that truncates the generated answer: answer = answer.slice(0, 4000) + (answer.length > 4000 ? '...' : '')

Source

  • Record date: 2026-09-21T08:45:39.290Z