Using Webhooks To Track Conversations In Real-Time

This guide explains how webhooks can be used to estimate total conversations for a given billing period.

Before starting this guide, make sure you understand Webhooks for the WhatsApp Business Platform.

Tracking Conversations With IDs

A conversation ID is generated whenever a business sends a message to a user outside of an existing conversation session. There is a charge when the first business message with this conversation ID is delivered, initiating the 24 hour conversation session.

There can be delays between when a message is sent and when it is delivered. One reason for this could be that the user’s phone is turned off when the message is delivered. If there is a delay, the conversation is processed as such: A conversation session is “pre-opened” when the message is sent. A corresponding conversation ID is associated with that conversation.

Once the message is delivered, the start time of the conversation session is refreshed.

The illustration below reflects an extreme example. Most messages are delivered within seconds of being sent.

Sent messages that are not delivered for 30 days are dropped. If conversation IDs are generated from sent but undelivered messages, there will not be conversation charges for those IDs.

Estimating Conversations Per Billing Period

To estimate costs, you need two pieces of information: the recipient’s country code and the conversation category. Both country code and conversation category are used to determine your rate. You can download the individual rate cards here.

To know a specific conversation's category, check the pricing object in your webhooks notifications. More details on how to identify the type of conversation in webhooks can be found in Status and Pricing Notifications.

Once you have the conversation category and recipient’s country code, calculate the number of conversations in the billing period by counting the number of unique conversation IDs that the webhook notification confirmed were delivered. Conversation IDs that just have a "sent" message status webhook notification associated with them will not be charged.

Total conversations per billing period

=

Number of unique conversation IDs associated with a webhook with status="delivered" and/or status="read" in that billing period.

You may only receive either a read or a delivered status notification in some cases. Either one confirms your message has been delivered. The most common scenario is you will receive both a read and delivered receipt.

If a conversation extends over two billing periods, there will be no additional charge in the following month when a conversation extends into the next billing period. The billing period for a conversation charge is determined by the timestamp of the first business message delivered in the conversation, using the timezone of the WABA.

Webhooks are the best tool for tracking conversation metrics in real-time.

See About Billing For Your WhatsApp Business Account for more information.