I'm implementing a whatsapp like chat using whatsapp business api.

There is the 24 hours rule where, in order to send a message to a whatsapp number, you need to send an approved template first. Afterwards, as soon as the user reply, the business account can send free form messages for the next 24 hours.

When a free form message is sent, the api returns this type of json:

{   "messaging_product": "whatsapp",   "contacts": [     {       "input": "<WHATSAPP_USER_PHONE_NUMBER>",       "wa_id": "<WHATSAPP_USER_ID>"     }   ],   "messages": [     {       "id": "<WHATSAPP_MESSAGE_ID>"     }   ] } 

However, this json does not guarantee that the message was delivered if sent outside of 24 hours. This json is always returned whether the conversation is open or not, and this doesn't help much.

So do you know if there is an api call that can tell me if the conversation is still open with the user?

Tag:whatsapp, whatsapp-cloud-api

3 comments.

  1. Nguyễn Phước Đại Toàn

    You need view webhook, error will be display in webhook:

    { "object": "whatsapp_business_account", "entry": [ { "id": "<ID>", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "<PHONE>", "phone_number_id": "<PHONE_ID>" }, "statuses": [ { "id": "<MESSAGE_ID>", "status": "failed", "timestamp": "1710392477", "recipient_id": "<PHONE_CUSTOMER>", "errors": [ { "code": 131047, "title": "Re-engagement message", "message": "Re-engagement message", "error_data": { "details": "Message failed to send because more than 24 hours have passed since the customer last replied to this number." }, "href": "https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes/" } ] } ] }, "field": "messages" } ] } ] }Run code snippet

    Hide resultsExpand snippet

    1. Jeremy Caney

      Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?

  2. Rinkesh

    Following response is example of cloud API notification type response,Once message is delivered to a user, in JSON response you will get statuses object, status key value as delivered/Sent .

    { "object": "whatsapp_business_account", "entry": [ { "id": "DUMMY_ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "XXXX", "phone_number_id": "XXXX" }, "statuses": [ { "id": "wamid.XXXXX", "status": "delivered", "timestamp": "1709882540", "recipient_id": "PHONE_NUMBER", "conversation": { "id": "e45e283030e944sd3rqd", "origin": { "type": "service" } } } ] }, "field": "messages" } ] } ] }

Add a new comment.