webhookswhatsappwhatsapp-cloud-api

Error replying on WhatsApp Webhook: Message failed to send because more than 24 hours have passed since the customer last replied to this number


I am programming a webhook for the WhatsApp Cloud API. I am receiving user-initiated messages well, but when I send text messages replying to said messages, I am getting the following JSON from the WhatsApp API:

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "MY_ID",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": {
              "display_phone_number": "NUMBER",
              "phone_number_id": "PHONE"
            },
            "statuses": [
              {
                "id": "wamid.ENCRYPTED_CODE",
                "status": "failed",
                "timestamp": "TIMESTAMP",
                "recipient_id": "ID",
                "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"
        }
      ]
    }
  ]
}

My initial message was:

{
  "recipient_type": "individual",
  "messaging_product": "whatsapp",
  "to": "MY_NUMBER",
  "text": {
    "body": "My message."
  },
  "type": "text"
}

I expected the message to be delivered, but instead I got the aforementioned error.


Solution

  • The error makes sense to me now: it happened because I changed my phone number from the test to a production one, but I forgot to update the WhatsApp ID in my code.

    Essentially, I was receiving messages correctly but sending them from the old test number.

    I updated the WhatsApp ID, and it works now. Thanks!