Browse guides

Full Round Trip

The complete lifecycle of one WhatsApp bot interaction — inbound webhook, reply logic, outbound API call, and status events confirming delivery.

On this page

One complete cycle of a bot conversation: customer sends → your bot decides → bot replies → Meta confirms delivery. Understanding this sequence is essential for building any WhatsApp bot.

The four stages#

Code
INBOUND → LOGIC → OUTBOUND → STATUS

Stage 1 — INBOUND#

Customer sends "Hi" from their phone:

Code
Customer's phone
      ↓  sends "Hi"
Meta servers receive it
      ↓
Meta POSTs JSON to your webhook URL
      ↓
Your server: [INBOUND] Text from 919959623255: Hi

Your code reads message.from (who) and message.text.body (what).

Stage 2 — LOGIC#

Your server decides what to reply:

js
const text = message.text.body.toLowerCase();

if (text === 'hi') {
  replyText = 'Hello! Type 1 for price, 2 for support.';
} else if (text === '1') {
  replyText = 'Pricing starts at ₹999/month.';
}

This is the bot brain — simple if/else for basic bots, AI for smarter ones.

Stage 3 — OUTBOUND#

Your server calls the Messages API to send the reply:

Code
Your server
      ↓  POST /messages
Meta API accepts it → returns message ID (wamid.xxx)
      ↓
Your server: [AUTO-REPLY] Sent to 919959623255
      ↓
Customer's phone receives the message

Stage 4 — STATUS#

Meta fires status events back to confirm delivery:

Code
Meta → POST /webhook → { "status": "sent" }
Meta → POST /webhook → { "status": "delivered" }
Meta → POST /webhook → { "status": "read" }

Full terminal output for one round trip#

Code
[INBOUND] Text from 919959623255: hi
[AUTO-REPLY] Sent to 919959623255: Hello! Type 1 for price...
[STATUS] sent      → 919959623255 | msg: wamid.HBgM...
[STATUS] delivered → 919959623255 | msg: wamid.HBgM...
[STATUS] read      → 919959623255 | msg: wamid.HBgM...

Frequently asked#

How does a WhatsApp bot work end to end?

Four stages — inbound (Meta POSTs customer message to your webhook), logic (your code decides the reply), outbound (you call Meta API to send the reply), status (Meta fires sent/delivered/read events back to confirm).

What is the difference between inbound and outbound?

Inbound = customer → Meta → your webhook (Meta calls you). Outbound = your server → Meta API → customer (you call Meta).

Gotchas & common mistakes#

Still stuck? Open a support ticket and our team will help.