Answer WhatsApp FAQs with keyword matching and an OpenAI fallback

Go to Workflow
0 views
Built by Zhang Lixiang Zhang Lixiang
Created on October 25, 2026

Description

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

This workflow was created by Zhang Lixiang and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.

Nodes Used (4)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
WhatsApp Business Cloud
n8n-nodes-base.whatsApp