O
OrderPin

WhatsApp Bot — Live Testing Guide

Connect your OrderPin bot to a real WhatsApp number using the Meta WhatsApp Cloud API, and run the Order Placing flow end‑to‑end from your own phone.

Meta WhatsApp Cloud API Local backend → public webhook ~30–45 min Updated June 2026
Terminal run on your Mac OrderPin in the admin portal Meta in developers.facebook.com
📋 What you'll set up

Three moving parts have to meet in the middle: (1) a public HTTPS tunnel so Meta can reach your local backend, (2) your Meta credentials entered into OrderPin's notification channel, and (3) Meta's webhook pointed back at your tunnel. Then you message the number and the bot replies.

Your phone ──"hi"──▶ Meta WhatsApp Cloud API ──webhook POST──▶ cloudflared tunnel ▲ │ │ ▼ bot reply (text/buttons) OrderPin backend :8001 │ /api/v1/whatsapp/webhook/ └───────────── engine runs "Order Placing" flow ◀── matches your number → Outlet

The 7 steps

  1. Prerequisites & checklist
  2. Expose your backend (tunnel)
  3. Create a Meta app + WhatsApp
  4. Collect Meta credentials
  5. Configure the channel in OrderPin
  6. Register your outlet (phone match)
  7. Connect the webhook in Meta
  8. Send a test message 🎉

0Prerequisites & checklist

Have these ready before you start. The first two are already true in your dev environment.

RequirementHow to confirm
Backend running on port 8001cd orderpin-backend && ./venv/bin/python manage.py runserver 8001
Frontend running on port 5175cd orderpin-frontend && npm run dev → log in at /admin/login
A published flow ("Order Placing")Already live. (Re-seed any time: ./venv/bin/python manage.py seed_order_flow)
A Facebook/Meta accountPersonal account is fine for testing.
Your phone with WhatsApp installedYou'll message the bot from it and it must be on Meta's test recipient list.
Homebrew (to install the tunnel)brew --version — or use ngrok instead (Step 1).
ℹ️ Cloud API only

OrderPin uses Meta's WhatsApp Cloud API (Meta‑hosted). The old On‑Premises API has been deprecated by Meta — you don't need it. Everything below uses the free test phone number Meta gives every app, so you can verify the full flow before bringing your own business number.

1Expose your backend to the internet

Meta's servers must reach your webhook, but your backend is on localhost:8001. A tunnel gives it a public HTTPS address.

Option A — cloudflared Terminal (recommended — free, no signup)

# install once
brew install cloudflared

# start the tunnel (leave this running in its own terminal tab)
cloudflared tunnel --url http://localhost:8001

It prints a line like:

+--------------------------------------------------------+
|  https://random-words-1234.trycloudflare.com           |
+--------------------------------------------------------+

That HTTPS address is your public base URL. Your webhook callback URL will be that + /api/v1/whatsapp/webhook/ — keep it handy for Step 6.

Option B — ngrok

brew install ngrok          # or download from ngrok.com
ngrok config add-authtoken <your-token>   # free account required now
ngrok http 8001

Use the https://…ngrok-free.app URL it shows.

✓ Already handled for you

Your dev settings have DEBUG=True and ALLOWED_HOSTS=['*'], so Django will happily accept requests arriving via the tunnel host — no extra config needed. Keep the tunnel running for the whole session; the URL changes each time you restart it (so you'd re-paste it in Step 6).

2Create a Meta app and add WhatsApp

This is all on Meta's side. Meta

  1. Go to developers.facebook.com and log in. If it's your first time, complete "Register as a Meta Developer" (you'll verify via phone/email and accept the terms).
  2. Top‑right → My AppsCreate App.
  3. For use case, pick "Other" → app type "Business" → give it a name (e.g. OrderPin Bot) and continue.
  4. On the new app's dashboard, find WhatsApp in the product list and click "Set up". This creates a free test WhatsApp Business Account and a test phone number for you automatically.
⚠️ Meta's dashboard changes often

Exact button labels and menu positions shift between updates. If something is named slightly differently, the official, always‑current walkthrough is WhatsApp Cloud API · Get Started. The concepts below don't change.

3Collect your credentials

From the app dashboard → WhatsApp → API Setup (sometimes "Getting Started"). Meta

You needWhere to find it
Phone number IDWhatsApp → API Setup, in the "From" section (a long numeric ID — not the phone number itself).
WhatsApp Business Account IDSame API Setup page, usually just below — or under WhatsApp → Configuration.
Access tokenAPI Setup page → "Temporary access token" (valid 24 hours — perfect for a test session). Click to copy.
App SecretApp dashboard → App Settings → BasicApp Secret → "Show".
Verify tokenYou invent this — any random string, e.g. orderpin-verify-7f3k9. You'll type the same value into OrderPin and Meta.

Add your phone to the recipient allow‑list

Test numbers can only message numbers you explicitly allow. On the API Setup page, in the "To" field, click "Manage phone number list" → add your personal WhatsApp number (with country code) → confirm the code WhatsApp sends you. You can add up to 5.

ℹ️ Token lifetimes

The temporary token expires after 24h — if testing the next day, just copy a fresh one from the same page and re‑save it in OrderPin (Step 4). For longer‑lived setups you'd create a System User token (Business Settings → Users → System Users) with the whatsapp_business_messaging permission — see "Beyond testing" at the end.

4Configure the channel in OrderPin

OrderPin reads all WhatsApp connection settings from one place: the Meta channel under Notifications. OrderPin

  1. In the admin portal go to Settings → Notifications → Channels. (Shortcut: the WhatsApp Automation page has a "Connect number" button that jumps here.)
  2. Add a channel of type WhatsApp, provider Meta Business API (meta_wa). Fill in:
FieldValue
Phone Number IDfrom Step 3
Access Tokenyour 24h temporary token
Business Account IDyour WABA ID
App Secretfrom App Settings → Basic verifies inbound webhooks
Webhook Verify Tokenthe random string you invented
  1. Enable the channel (the Enabled toggle). 🔑 This is what flips the bot from console mode to live — it's the single switch that makes the bot actually send messages through Meta.
  2. Save.
🔑 The #1 gotcha

If the channel is not enabled, the bot still receives your messages but logs its replies to the backend console instead of sending them — so you'll see nothing on your phone. Make sure the toggle is ON.

5Register your outlet (so the bot recognises you)

The bot identifies a sender by matching their WhatsApp number to an Outlet.phone (last 10 digits). OrderPin

The seeded demo outlets use fake numbers (9876500001…), so the bot won't know your real phone yet. Fix it in one of two ways:

The match is forgiving about the country code: if you message from +91 98765 43210, it matches an outlet stored as 9876543210.

⚠️ Unknown numbers get a polite refusal

If the sender's number doesn't match any outlet, the bot replies "this number isn't linked to a registered outlet" and stops — by design. That's your signal that Step 5 wasn't done.

6Connect the webhook in Meta

Now tell Meta where to deliver incoming messages. Meta

  1. App dashboard → WhatsApp → Configuration → in the Webhook section click Edit.
  2. Callback URL: your tunnel URL + the webhook path:
    https://random-words-1234.trycloudflare.com/api/v1/whatsapp/webhook/
  3. Verify token: the exact same random string from Step 3/4.
  4. Click Verify and Save. Meta immediately sends a GET with a challenge; OrderPin's webhook checks your verify token and echoes it back. ✅ Success = the dialog closes without error.
  5. Back on the Configuration page, under Webhook fields, click Manage and Subscribe to the messages field. This is mandatory — without it, no inbound messages are delivered.
ℹ️ What "Verify and Save" actually does

Meta calls GET …/whatsapp/webhook/?hub.mode=subscribe&hub.verify_token=…&hub.challenge=…. OrderPin compares the token to the one on your channel and returns the hub.challenge verbatim. If verification fails, it's almost always a token mismatch or the tunnel isn't running.

7Send a test message 🎉

Everything's wired. Time to talk to your bot.

  1. Open WhatsApp on your phone and start a chat with the test number shown on Meta's API Setup page (save it to contacts first, or tap the link Meta provides).
  2. Send hi.
  3. You should receive, in order:
    • 👋 "Hi <your outlet name>! Let's build your order."
    • A tappable product list (Browse Catalog)
    • A prompt: "How many units…?" → reply with a number
    • An Add another / Checkout menu → tap Checkout
    • 🎉 "Order ORDxxxx placed! Total ₹…"
  4. Back in OrderPin, open Orders — your new order is there. Open WhatsApp → Conversations to see the full transcript.
✓ That's a real, end‑to‑end order over WhatsApp

The same number now runs whichever flow is most recently published. Edit "Order Placing" (or build a new flow) in the builder, hit Publish, and the live bot updates instantly — no Meta reconfiguration needed.


🛠 Troubleshooting

SymptomLikely cause & fix
"Verify and Save" fails in MetaVerify token doesn't match the channel's, or the tunnel isn't running / the URL changed. Re‑copy the current tunnel URL and the exact token.
I message the bot, nothing comes back① Channel not Enabled (replies log to console). ② messages field not subscribed. ③ Your number isn't on Meta's recipient allow‑list. ④ Token expired (grab a fresh 24h one).
"This number isn't linked to a registered outlet"Step 5 — set an outlet's phone to your real number.
Bot says "no products available"No stock. Run ./venv/bin/python manage.py seed_order_flow (it tops up demo stock), or sync/seed stock for the outlet's warehouse.
Webhook returns 403Signature check failed — the App Secret in the channel doesn't match the app. Re‑copy it from App Settings → Basic. (Leaving App Secret blank disables the check — fine for a quick test, not for production.)
Replies are delayed or stop after a whileWhatsApp's 24‑hour customer‑service window: the bot can only send free‑form messages within 24h of the user's last message. Just message it again to reopen the window.

Watch it live

Keep an eye on the backend terminal (the one running runserver 8001) while you test — every inbound delivery shows as a POST /api/v1/whatsapp/webhook/ 200 line, and console‑mode replies print there too.

📌 Quick reference — your setup

ItemValue
Backendhttp://localhost:8001
Admin portalhttp://localhost:5175/admin
Webhook path/api/v1/whatsapp/webhook/
Full callback URLhttps://<tunnel>/api/v1/whatsapp/webhook/
Channel configSettings → Notifications → Channels → Meta Business API
Live switchthe channel's Enabled toggle
Identity matchsender's WhatsApp # → Outlet.phone (last 10 digits)
Live botthe most recently published flow (currently "Order Placing")
Re‑seed flow + stock./venv/bin/python manage.py seed_order_flow

🚀 Beyond testing (toward production)