DEVELOPER GUIDE

How to prevent duplicate WhatsApp messages

Use idempotency keys and durable event records so retries never become duplicate customer alerts.

Developer guide for duplicate messages. Validate the behavior in your own stack before production rollout.

The problem

Derive one key from the source event revision and recipient before the first send.

Timeline: a send times out, the retry sends again without a key, but with the same Idempotency-Key ChatRail replays the original 202 and only one message is sent
Most duplicates are a lost response followed by a retry that looks like a new send.

Design the boundary

Send the same key on every retry and store the resulting message ID against the source event.

An order.shipped event (evt_4821) mapped to one Idempotency-Key, with four outcomes: 202 first send, 202 retry replayed, 409 still in flight, 422 different body
Derive the key from the event revision and recipient, not from a random value per attempt.

Process the interaction

Treat timeouts as unknown outcomes; retry with the original key and cap attempts.

Two WhatsApp chats: one shows the same shipping alert twice and a confused customer, the other shows it once and a useful reply
One alert keeps the conversation about the order, not about the duplicate.

Measure the outcome

Measure duplicate conflicts, retry count and dead-lettered sends.

BUILD IT SAFELY

Make the failure path part of the design.

Reliable messaging is an operational system, not only an API call.

Start free