netflie / whatsapp-cloud-api

The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform
https://netflie.es/portfolio/whatsapp-business-cloud-api-php-sdk/
MIT License
424 stars 151 forks source link

Error when message of type user_changed_number is received. #120

Open muniter opened 1 year ago

muniter commented 1 year ago

Error processing the webhook when a user changes its phone number.

Payload

Note: Personal data has been redacted with X

{
    "object": "whatsapp_business_account",
    "entry": [
        {
            "id": "108XXXXXXXXXXXX",
            "changes": [
                {
                    "value": {
                        "messaging_product": "whatsapp",
                        "metadata": {
                            "display_phone_number": "573XXXXXXXXX",
                            "phone_number_id": "10XXXXXXXXXXXXX"
                        },
                        "messages": [
                            {
                                "from": "573XXXXXXXXX",
                                "id": "wamid.HBgMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==",
                                "timestamp": "1687834799",
                                "system": {
                                    "body": "User A changed from \\u200e573XXXXXXXXX to 573XXXXXXXXX\\u200e",
                                    "wa_id": "573XXXXXXXXX",
                                    "type": "user_changed_number"
                                },
                                "type": "system"
                            }
                        ]
                    },
                    "field": "messages"
                }
            ]
        }
    ]
}

Stack trace

exception: 'Undefined index: customer',

#0 /app/vendor/netflie/whatsapp-cloud-api/src/WebHook/Notification/MessageNotificationFactory.php(99): yii\\base\\ErrorHandler->handleError(8, \'Undefined index...\', \'/app/vendor/net...\', 99, Array)
#1 /app/vendor/netflie/whatsapp-cloud-api/src/WebHook/Notification/MessageNotificationFactory.php(9): Netflie\\WhatsAppCloudApi\\WebHook\\Notification\\MessageNotificationFactory->buildMessageNotification(Array, Array)
#2 /app/vendor/netflie/whatsapp-cloud-api/src/WebHook/NotificationFactory.php(29): Netflie\\WhatsAppCloudApi\\WebHook\\Notification\\MessageNotificationFactory->buildFromPayload(Array, Array, Array)
#3 /app/vendor/netflie/whatsapp-cloud-api/src/WebHook.php(32): Netflie\\WhatsAppCloudApi\\WebHook\\NotificationFactory->buildFromPayload(Array)
#4 /app/modules/Whatsapp/controllers/DefaultController.php(44): Netflie\\WhatsAppCloudApi\\WebHook->read(Array)
...
aalbarca commented 12 months ago

Hi @muniter, which graph api version are you using? Thanks.