Guide · AI automation · Restaurants & cafes

Restaurant WhatsApp AI automation: QR ordering, an AI Captain and guests who come back

From our reel: most restaurants lose every guest the moment they pay the bill. One QR code on the table fixes that. It opens WhatsApp, where an AI Captain answers menu questions and takes the order, then a quiet automation brings the guest back. Below is the full flow and the Claude prompts to build it on the WhatsApp API through MSG91.

A restaurant WhatsApp automation workflow: table QR scan, WhatsApp opt-in, the AI Captain answering menu questions and taking the order, order complete, then a Google review request, and a birthday trigger that sends a gift offer so the customer returns
Top: a guest orders. Bottom: what runs on its own afterwards, like the birthday treat on the phone.
Answer capsule

What is a restaurant WhatsApp AI automation?

It's a WhatsApp chatbot for your restaurant that starts from a table QR code, answers questions from your real menu, takes the order, and then keeps the guest coming back with messages that send themselves. It runs on the official WhatsApp Business API (here through MSG91), an AI model, and a small server. Nothing to install for the guest. For the owner, it's restaurant marketing that turns a one-time visit into a regular.

One visit, start to finish

A guest's visit, told in WhatsApp messages

This is what Priya sees on her phone. Every step on the left is a line on the right.

  1. Scan

    One QR code on the table opens WhatsApp with a message already typed. No app, no menu card.

  2. Opt in

    The guest shares their name and gets a free-item code. That's their yes to hearing from you on WhatsApp.

  3. Order

    The AI Captain answers menu questions from your real menu and takes the order in the same chat.

  4. Review

    After the meal it asks for a Google review, so the next guest finds you.

  5. Come back

    From then on the automation brings them back on its own, with offers nobody has to remember to send.

Café AromaAI Captain · WhatsApp
  1. Table 6 · 8:12 PM
  2. Guest: Hi! Table 6
  3. AI Captain: Welcome to Café Aroma! 🎉 What's your name? Share it and get a free dessert on your next visit (valid 14 days). Reply STOP anytime.
  4. Guest: Priya
  5. AI Captain: Thanks, Priya! Your code is DSRT42 🍰 Want the menu, or ask me anything.
  6. Guest: Anything gluten-free?
  7. AI Captain: Yes, 3 on our menu: Paneer Tikka (₹280), Veg Biryani (₹320), Thai Green Curry (₹340). Add one?
  8. Guest: 1 Paneer Tikka and 1 Thai curry
  9. AI Captain: Table 6: Paneer Tikka ×1, Thai Green Curry ×1. Total ₹620. Confirm? Yes / No
  10. Guest: Yes
  11. AI Captain: Sent to the kitchen ✅
  12. After the meal
  13. AI Captain: Hope you enjoyed it, Priya! Could you leave us a quick Google review? ⭐
  14. 7 days later
  15. AI Captain: Your free dessert is still waiting 🍰 Code DSRT42 is valid for 7 more days.
  16. On her birthday
  17. AI Captain: 🎂 Happy Birthday, Priya! A free dessert is waiting for you this week.
Demo chat with a sample menu and made-up guest.
Runs automatically

What keeps the guest coming back

Five messages nobody on your staff has to remember to send.

After the meal

Google review ask

One message with your review link. Never twice in a week, and never after a complaint.

Day 7

Free-item reminder

If the code from the first visit hasn't been used: “your free dessert is still waiting.”

Their birthday

Birthday treat

A gift offer in the week of their birthday, if they shared it.

After they return

Bring a friend

Once the free item is redeemed, a referral code for a friend.

Day 30

Win-back nudge

No visit in a month? A short note with a reason to come back.

Build it with Claude + MSG91

7 Claude prompts to build the WhatsApp AI chatbot

Paste them in order into one Claude chat (or Claude Code). Together they build a small Node.js app that talks to the WhatsApp API through MSG91: the QR opt-in, the AI Captain, the review ask and the automatic messages. Before you start you need an MSG91 account with your WhatsApp number connected, an AI API key, and a server with HTTPS.

  1. 1. Set up the project and the MSG91 sender

    Start here. Everything else sends through these two functions.

    You are a senior Node.js developer. Create a small Node.js (Express) project for a restaurant's WhatsApp assistant that talks to WhatsApp through MSG91.
    
    Read secrets from environment variables only, never hard-code them: MSG91_AUTHKEY, MSG91_INTEGRATED_NUMBER (the WhatsApp number connected in MSG91, digits with country code), ANTHROPIC_API_KEY (or OPENAI_API_KEY), GOOGLE_REVIEW_URL, MANAGER_WHATSAPP, KITCHEN_WHATSAPP.
    
    Write msg91.js with two functions:
    1. sendText(to, text): a free-form session message, which WhatsApp only allows within 24 hours of the customer's last message. POST to MSG91's WhatsApp outbound message endpoint (https://api.msg91.com/api/v5/whatsapp/whatsapp-outbound-message/) with the authkey header, integrated_number, the recipient number and content_type "text".
    2. sendTemplate(to, templateName, bodyVariables, languageCode = "en"): an approved template message via https://api.msg91.com/api/v5/whatsapp/whatsapp-outbound-message/bulk/ with a body like:
    { "integrated_number": "...", "content_type": "template", "payload": { "messaging_product": "whatsapp", "type": "template", "template": { "name": "...", "language": { "code": "en", "policy": "deterministic" }, "namespace": null, "to_and_components": [ { "to": ["91XXXXXXXXXX"], "components": { "body_1": { "type": "text", "value": "..." } } } ] } } }
    
    Check both request shapes against MSG91's current WhatsApp API docs before you finish, and tell me anything that differs. Normalise Indian numbers to 91XXXXXXXXXX. Log every send (to, type, status) and return MSG91's response. Add .env.example and a README section on the env vars.
  2. 2. Receive messages from MSG91

    Paste the webhook URL into MSG91 → WhatsApp → your number → Webhooks.

    Add POST /webhooks/msg91/inbound for MSG91's inbound WhatsApp webhook. Parse the sender number, message text, message id and timestamp. Log the raw body the first time so we can confirm MSG91's field names, and adjust the parser to match.
    
    Ignore duplicate deliveries by message id. Respond 200 fast and process asynchronously.
    
    Store customers in SQLite (better-sqlite3) with: phone, name, opted_in (bool), opted_in_at, state (which question we're waiting on), last_message_at, birthday (nullable, DD-MM), free_item_code, code_expires_at, code_redeemed_at, visits, referral_code, referred_by, last_marketing_at.
    
    If the text is STOP, set opted_in = false, confirm in one line, and never send that number anything again unless they message START.
    
    Add POST /webhooks/msg91/status for sent / delivered / read / failed receipts and store them against the message.
  3. 3. Table QR, opt-in and the free-item code

    Print one QR per table. The table number rides along in the message.

    Create the table QR flow.
    
    1. A script that writes printable QR PNGs for tables 1–20 (qrcode npm package). Each QR is a wa.me click-to-chat link to MSG91_INTEGRATED_NUMBER with the prefilled text "Hi! Table {n}".
    2. When a new number messages us: reply (as a session message) with a short welcome that asks for their name, says they'll get updates and offers from us on WhatsApp, and says they can reply STOP anytime. Remember the table number.
    3. When they reply with a name: save it, set opted_in = true with a timestamp, create a unique 6-character free-item code valid 14 days, and send it.
    4. Optionally ask for their birthday as DD-MM so we can send a birthday treat. Accept "skip".
    
    Use the customer's state field so each reply is matched to the question we asked. Handle someone who scans again later: greet them by name, no second code.
  4. 4. The AI Captain: menu answers and orders

    Give it your real menu. This is the step that stops it inventing dishes.

    Add the AI Captain. Load menu.json (I'll paste the real menu): each item has id, name, category, price, veg (true/false), tags such as "gluten-free", "jain", "spicy", and available (true/false).
    
    For any message from an opted-in customer that isn't an answer to an opt-in question, call the AI model with a system prompt that says:
    - You are the restaurant's WhatsApp captain.
    - Answer ONLY from the menu JSON you are given. If a dish, price, ingredient or offer isn't in it, say you're not sure and offer to call a staff member.
    - Never invent dishes, prices, offers or ingredients.
    - Reply in the customer's language (English, Hindi or Hinglish), under 60 words.
    
    Have the model also return order actions as JSON (add item id + qty, remove, confirm). Validate every item id against menu.json and skip unavailable items. Keep a cart per customer. On confirm, show the order with total and table number and ask "Confirm? Yes / No". On Yes, save the order and send it to KITCHEN_WHATSAPP with sendText (log it too).
    
    Add tests for: "anything gluten-free?", a dish that isn't on the menu, and a two-item order with one change.
  5. 5. Ask for the Google review

    Ask once, at the right moment, and never after a complaint.

    When an order is marked served (add POST /orders/:id/served for staff, with a 90-minute fallback timer), send the approved template "review_request" with the customer's name and GOOGLE_REVIEW_URL.
    
    Send it once per visit and at most once in 7 days. If the customer's recent messages read as a complaint (ask the AI model to classify sentiment), don't send the review link. Forward the complaint to MANAGER_WHATSAPP instead.
  6. 6. Birthday, win-back and bring-a-friend, on autopilot

    This is the part that brings customers back without anyone remembering.

    Add a daily scheduler (node-cron, 11:00 IST) that sends approved templates to opted-in customers only:
    1. birthday_treat on their birthday (if we have it).
    2. free_item_reminder 7 days after the code was issued, if it hasn't been redeemed and hasn't expired.
    3. refer_friend the day after a customer redeems their free item, with their referral_code.
    4. win_back 30 days after the last visit.
    
    Add POST /codes/:code/redeem for staff: it marks the code redeemed, counts a visit, and credits referred_by if the code was a referral.
    
    Rules: at most one marketing message per customer per 7 days, skip anyone opted out, log every send, and a DRY_RUN=true mode that prints what would be sent without sending.
  7. 7. Test it and go live

    Run the whole thing on your own number before a single guest sees it.

    Write a test plan and a go-live checklist for this project:
    1. Run everything with DRY_RUN=true and my own number as the only customer, scan to birthday.
    2. The exact WhatsApp templates to submit for approval in MSG91 (review_request, birthday_treat, free_item_reminder, refer_friend, win_back), with suggested text in English and Hinglish, their variables, and the right category (utility or marketing).
    3. How to set the inbound and status webhook URLs in MSG91.
    4. Deployment on a small server or Cloud Run with HTTPS, and where to keep the env vars.
    5. What to monitor each week: failed sends, opt-outs, template rejections, and orders that never got confirmed.

Rather not wire up webhooks and templates yourself? We'll hand you the working MSG91 integration code, or run the whole setup on your number.Get the integration code

Before you launch

4 things to know first

01

Templates outside the 24-hour window

Replies inside 24 hours of the guest's last message can be free-form. Everything after that (review ask, reminders, birthday, win-back) needs a template approved by Meta. Submit them in MSG91 before launch.

02

Opt-in first, STOP always works

Message only guests who opted in by scanning and sharing their name. Honour STOP instantly. Bulk-messaging from a personal WhatsApp number is how numbers get banned. This uses the official API instead.

03

Every template message costs a little

Meta charges per template message, billed through your provider (MSG91 here). Session replies to a guest who just messaged you are usually much cheaper. Check MSG91's current rates and cap marketing to one message a week.

04

Menu-only answers, always

The AI Captain answers only from your menu file, with prices and availability from that file, and says “not sure” otherwise. Update menu.json when the menu changes, and it never quotes a dish you don't serve.

Compared

QR code menu vs. delivery apps vs. a WhatsApp AI Captain

Three ways a restaurant handles the guest at the table
QR code menu (PDF)Delivery appsWhatsApp AI Captain
Who has the guest's numberNobodyThe delivery appYou, with their opt-in
Answers “anything gluten-free?”NoFilters, no questionsYes, from your real menu
Takes the order at the tableNo, a waiter doesNot for dine-inYes, in the WhatsApp chat
Asks for a Google reviewNoReviews stay on the appYes, after the meal
Brings the guest backNoThe app's offers, on the appBirthday, win-back and referral messages
What it costsFreeCommission on every orderPer-message WhatsApp fees + a one-time setup
FAQ

Restaurant WhatsApp chatbot questions

Can a WhatsApp chatbot take restaurant orders?
Yes. With the WhatsApp Business API, a chatbot can read the guest's messages, answer menu questions and build an order in the chat, then send it to the kitchen. The guest never installs anything; they scan a QR code and WhatsApp opens.
Do I need the WhatsApp Business API, or is the WhatsApp Business app enough?
You need the API. The free WhatsApp Business app can't be connected to an AI or an automation, and bulk-sending from it risks a ban. The API is accessed through a provider such as MSG91, which gives you webhooks, templates and sending.
What is MSG91, and why use it for WhatsApp?
MSG91 is an Indian messaging platform and WhatsApp Business provider. It connects your number to the official WhatsApp API, manages template approvals, sends messages over a simple REST API, and delivers incoming messages to your webhook. The prompts on this page are written for it.
Will the AI make up dishes or prices?
Not if it's built the way prompt 4 says: it only answers from your menu file, every ordered item is checked against that file, and anything it isn't sure about goes to a staff member. That rule is the most important line in the whole build.
How much does it cost to run?
Three parts: WhatsApp message charges (Meta's per-message fees, billed through MSG91), the AI model's usage (a few paise per reply), and a small server. There's no per-order commission. Check MSG91's current WhatsApp pricing for your volume.
Is a QR code menu enough on its own?
A QR code that opens a PDF menu saves printing, but the guest still leaves without you having any way to reach them. Pointing the same QR at WhatsApp turns one scan into an opted-in customer you can bring back.

Get the WhatsApp integration code

Tell us about your restaurant or cafe. We'll send the working MSG91 + WhatsApp integration code, or set up the AI Captain for you on your number, with your menu. See the full WhatsApp automation service.

  • QR opt-in and free-item codes
  • AI Captain that answers only from your menu
  • Review ask, birthday, win-back and referral messages

Prefer to chat? DM us on Instagram

No payment on this form. We use your details only to reply to this request. See our privacy policy.