Quick overview
This workflow handles WhatsApp Business Cloud API webhooks, verifies the callback URL, and replies to incoming WhatsApp text messages using keyword-matched FAQs with an OpenAI fallback that can only select from approved FAQ IDs before sending the stored answer back via WhatsApp.
How it works
- Receives a GET request from Meta to verify the WhatsApp webhook and returns the hub.challenge only when the provided verify token matches.
- Receives WhatsApp webhook POST events and keeps only incoming text messages while ignoring delivery/read receipts.
- Scores each message against a built-in FAQ list using keyword matching and selects the highest-scoring FAQ answer when a match is found.
- If no keyword match is found, sends the customer message plus the FAQ IDs and questions to an OpenAI chat model to choose a single FAQ ID or null.
- Validates the model’s output against the known FAQ IDs and selects either the corresponding stored answer or a fixed fallback message.
- Sends the chosen reply back to the customer via the WhatsApp Business Cloud API using the same phone number that received the message.
Setup
- Create a Meta app with the WhatsApp product, connect a business phone number, and configure webhook subscriptions for messages.
- In n8n, add WhatsApp Business Cloud API credentials and an OpenAI (or OpenAI-compatible) credential for the chat model node.
- Replace YOUR_VERIFY_TOKEN in the webhook verification check and use the same token in Meta’s webhook settings.
- Activate the workflow and copy the production webhook URL for the whatsapp-faq path into Meta’s webhook configuration.
- Edit the FAQ list (IDs, questions, keywords, answers) and update placeholders like YOUR_BOOKING_LINK and the fallback message to match your business.
Additional info
Need signature verification, deduplication, opt-out handling and human handoff? A production version is available at https://zhangautomation.gumroad.com/l/ecvlr