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
484 stars 177 forks source link

PHP Fatal error: Uncaught UnexpectedValueException: Value 'user_initiated' #78

Closed derrickobedgiu1 closed 1 year ago

derrickobedgiu1 commented 1 year ago

Discussed in https://github.com/netflie/whatsapp-cloud-api/discussions/76

Originally posted by **derrickobedgiu1** January 29, 2023 The new version is having a typo somewhere: PHP Fatal error: Uncaught UnexpectedValueException: Value 'user_initiated' is not part of the enum Netflie\WhatsAppCloudApi\WebHook\Notification\Support\ConversationType Apparently instead of user_initiated, it's having customer_initiated PATH: Netflie\WhatsAppCloudApi\WebHook\Notification\Support\ConversationType I was using the previous version to send messages but all status updates about the conversation type the user initiated have been of type "user_initiated", even though the DOC says customer_initiated. Maybe these occur for certain status update types I haven't used yet Sample status updates webhook payload I always receive : ```php { "object": "whatsapp_business_account", "entry": [ { "id": "114392761549803", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "256*********", "phone_number_id": "112************" }, "statuses": [ { "id": "wamid.HBgMMjU2NzQyMDMwNDAzFQIAERgSQTYzODBCOTQ5RThGRDUzQTFEAA==", "status": "sent", "timestamp": "1674902805", "recipient_id": "2567********", "conversation": { "id": "f5e244bb2b0e4ee8065116ff20f5fe76", "expiration_timestamp": "1674926460", "origin": { "type": "user_initiated" } }, "pricing": { "billable": true, "pricing_model": "CBP", "category": "user_initiated" } } ] }, "field": "messages" } ] } ] } ```
aalbarca commented 1 year ago

@derrickobedgiu1 Fixed in 2.0.1 version, can you test it?

Thanks.

derrickobedgiu1 commented 1 year ago

Working fine now. Maybe you could add the sample code to Mark Message as Read in the README file as it's not available. Some people might start asking. And a little suggestion to optionally include the [context] field that can be sent along with a message to reply to a given message id. If the user doesn't pass it can be nulled out. This can be introduced in future updates, also the ButtonLists aren't yet available. Meanwhile, the fix in 2.0.1 is working fine without any errors being logged on my end.

aalbarca commented 1 year ago

Please @derrickobedgiu1 you're free to open a PR with your requests. This is an open source code and everyone can collaborate.

Thanks!