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
449 stars 163 forks source link

Send Reply to Text Message #98

Closed josimarcordeiro closed 9 months ago

josimarcordeiro commented 1 year ago

According to the WhatsApp API documentation, it is possible to send a response message by including the context > message_id parameter in the request body. How to do this with your library?

{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "{{Recipient-Phone-Number}}", "context": { "message_id": "<MSGID_OF_PREV_MSG>" }, "type": "text", "text": { "preview_url": false, "body": "<TEXT_MSG_CONTENT>" } }

johnflash4real commented 1 year ago

I'm Having the same challenge here... I've looked through the codebase and can see that the MessageRequest body doesn't include the context parameter.

I Might just need to make a fork and try to add it myself or something...

johnflash4real commented 1 year ago

@josimarcordeiro I've implemented a method for this in https://github.com/johnflash4real/whatsapp-cloud-api/tree/add-reply-buttons

I Made it as simple as calling a chainable method

$whatsAppApi->asReplyTo($originalMsgId)->sendTextMessage(...);

Also added replyButtons as that was missing.

aalbarca commented 1 year ago

Hi @johnflash4real I saw a lot of improvements in your repository. You should to try open new PR on this main repository to help to the all community :pray:

johnflash4real commented 1 year ago

@aalbarca Yeah, I would love to... Except that I haven't found the time to add tests for my changes yet. Did it pretty much in a rush.

josimarcordeiro commented 1 year ago

Hi @aalbarca Congratulations on the excellent work you are doing here. Could you implement this functionality in the next version?

aalbarca commented 9 months ago

@josimarcordeiro the feature will be released today.