You want a WhatsApp bot that replies to customers, takes orders, or handles support. The official WhatsApp Business API is a maze of approvals and docs. Most "build a bot in 5 minutes" tutorials skip the part where the bot actually has to do something.
This guide builds a working WhatsApp bot end to end on FlowEngine Functions. It uses the chatbot template, plugs in your WhatsApp instance, and gives you a bot you can point at any logic you want.
Skill level: intermediate. Time required: about 10 minutes. You'll need a FlowEngine account, a phone number for WhatsApp, and a quiet 10 minutes.
What You'll Build
A WhatsApp number that receives messages, runs them through code you control, and replies. Out of the box the template echoes back what the user said with a small twist. By the end of this guide you'll know how to swap that for any logic: keyword routing, an LLM reply, a database lookup, an order flow.
Before You Start
- A FlowEngine account. Sign up at flowengine.cloud, free.
- A phone number you can dedicate to WhatsApp Business. A spare SIM, a SMS-receivable virtual number, or your real number all work.
- About 10 minutes.
Step 1: Provision a WhatsApp Instance
FlowEngine ships a managed WhatsApp API instance on the hosting side. From the portal sidebar, open Hosting, click Deploy, pick WhatsApp as the service type. Give it a name and wait about a minute for the status to flip to running.
Once it's up, the detail page shows three things you'll need: the API URL, the instance name, and the API key. Keep that tab open.
Step 2: Pair Your Phone Number
Still on the WhatsApp instance detail page, click Connect. A QR code appears.
Open WhatsApp on your phone, go to Settings > Linked Devices > Link a Device, and scan the QR code. The instance reports connected. Your phone number is now wired up.
Step 3: Fork the Chatbot Template
Open Functions in the portal sidebar, click New Function, then click Templates. Find the WhatsApp chatbot template and click Use template.
The template clones into your account as a working Node.js function. It comes pre-wired with a webhook handler that parses incoming WhatsApp messages and sends a reply. The code is short, readable, and yours to modify.
Step 4: Connect the Function to Your Instance
The template needs three secrets to talk to your WhatsApp instance:
FLOWENGINE_WHATSAPP_API_URLFLOWENGINE_WHATSAPP_INSTANCEFLOWENGINE_WHATSAPP_API_KEY
Copy those values from the instance detail page in Step 1. On the function detail page, open the Secrets tab and paste them in. Click Deploy. Status flips to ready.
Step 5: Register the Webhook
WhatsApp needs to know where to send incoming messages. Back on the WhatsApp instance detail page, find the Webhook URL field. Paste in your function's URL (from the function detail page) and save.
Now every message someone sends to your WhatsApp number will hit your function.
Step 6: Test It
Send a WhatsApp message to your number from a different phone. Within a second or two you should get a reply.
Open the function's Logs tab in the FlowEngine portal. You'll see the incoming webhook, the parsed message body, and the outgoing reply, all in one structured log entry. If something doesn't work, the error will be in that log, not in some external dashboard.
Step 7: Make It Do Something Useful
The template's reply logic is one function in index.js. Right now it echoes the message. Some quick replacements:
Keyword router. If the user types "hours," reply with your business hours. If "menu," send the menu. A switch statement covers most small businesses.
const text = (message.text || '').toLowerCase().trim();
if (text === 'hours') return reply('We are open Mon-Fri 9-5.');
if (text === 'menu') return reply('1. Pizza\n2. Pasta\n3. Salad');
return reply('Type "hours" or "menu" to get started.');
LLM reply. Forward the message to OpenAI (or whichever model you like) and send the answer back. Add an OPENAI_API_KEY secret and 15 lines of code.
Order capture. Recognize "order pizza," collect a delivery address in the next message, store the order in your database, send a confirmation. A small state machine in code.
Common Mistakes
- Webhook URL not saved on the WhatsApp instance. Messages arrive at the instance, never reach your function. Verify in the instance settings.
- Wrong secret values. A typo in
FLOWENGINE_WHATSAPP_API_KEYmeans the function gets the message but can't send a reply. Check the function logs for 401 responses. - Phone number not linked. The instance shows disconnected. Re-scan the QR code from your phone.
- Free-tier timeout. If your bot calls an LLM that takes 20 seconds, the free 15-second timeout will cut it off. Upgrade to Pro for 15-minute timeouts.
Going Further
Once the bot is live, the same function can grow into a full automation surface. Use the cron trigger on FlowEngine Functions to send a daily reminder to a customer. Use workspace secrets to share an OpenAI key across the bot and other functions. Forward the conversation log to a hosted n8n workflow if you want to do CRM enrichment or notification routing.
For higher-volume operations or businesses that need multiple bots, FlowEngine Teams gives you longer timeouts, more memory, and Slack triggers in addition to WhatsApp.
Wrapping Up
A working WhatsApp bot is one provision, one fork, three secrets, and one webhook URL. Most of the work is the logic you write in the function, not the plumbing.
Sign up for FlowEngine free and ship your first WhatsApp bot today. No credit card required.
