Order updates

Send order updates with useful WhatsApp follow-ups

Turn a trusted order event into a concise WhatsApp update, then route customer questions without confusing message delivery with fulfillment state.

Level
Intermediate
Time
14 minutes
Stack
HTTP · Webhooks
Order event, WhatsApp alert and reply webhook workflow
The production boundary used throughout this tutorial.
01

Start from a trusted order event

Your commerce system remains the source of truth. Send only after it confirms a real transition such as order.dispatched, and persist the source event ID before making the API request.

02

Attach a small context contract

Include only facts a customer may ask about. Keep payment data, fraud notes and unrelated history out of the messaging boundary.

order-context.json
{
  "schema_version": 1,
  "order_id": "CR-2048",
  "status": "dispatched",
  "estimated_delivery": "2026-09-17",
  "address_change_allowed": false,
  "carrier": "Example Courier"
}
03

Send once, retry safely

Derive an idempotency key from the order revision and recipient. A network retry should return the original result instead of creating a second notification.

Terminal
curl -X POST https://api.chatrail.dev/v1/messages/text \
  -H "Authorization: Bearer $CHATRAIL_API_KEY" \
  -H "Idempotency-Key: order-CR-2048-dispatched" \
  -H "Content-Type: application/json" \
  -d '{"connection":"studio-shop","to":"+14155550142",
       "body":"Order CR-2048 has shipped. ETA: Thursday."}'
04

Set boundaries for replies

Facts such as ETA and carrier can be answered from context. Refunds, cancellations and identity changes should enter an authenticated application flow or a human queue.

Do not let conversational access become authorization.

A WhatsApp reply alone should never approve a refund, address change or account-sensitive action.

05

Keep message and order state separate

A WhatsApp delivered event confirms delivery to the account—not delivery of the parcel. Store messaging events separately and tolerate out-of-order status updates with monotonic transitions.

06

Test the failure paths

Repeat the same source event, deliver read before delivered, disconnect the linked device and request a restricted action. Each case should finish in a safe, observable state.

  • Duplicate event creates one message
  • Out-of-order status stays correct
  • Disconnected session holds the send
  • Restricted action escalates
STRAIGHT ANSWERS

Questions before you build?

Start with the documentation or review the practical answers below.

Is ChatRail the official Meta Cloud API?

No. ChatRail uses a WhatsApp Linked Devices session. Review the transport trade-offs before production use.

Can I use it without AI?

Yes. Sending, delivery tracking and webhooks work without enabling AI.

Where should I start?

Use the Quickstart for your first request, then choose a workflow tutorial.