From 9ebe85343dc61300613e528ba2f40083b76346f7 Mon Sep 17 00:00:00 2001 From: Derrick Obedgiu Date: Sun, 13 Aug 2023 02:28:12 +0300 Subject: [PATCH 1/6] Add button reply message section --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index c8f4b0f..1c40126 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,36 @@ $whatsapp_cloud_api->sendList( ); ``` +### Send a button reply message + +```php + 'your-configured-from-phone-number-id', + 'access_token' => 'your-facebook-whatsapp-application-token' +]); + +$rows = [ + new Button('button-1', 'Yes'), + new Button('button-2', 'No'), + new Button('button-3', 'Not Now'), +]; +$action = new ButtonAction($rows); + +$whatsapp_cloud_api->sendButton( + '', + 'Would you like to rate us on Trustpilot?', + $action, + 'RATE US', // Optional: Specify a header (type "text") + 'Please choose an option' // Optional: Specify a footer +); +``` + ## Media messages ### Upload media resources Media messages accept as identifiers an Internet URL pointing to a public resource (image, video, audio, etc.). When you try to send a media message from a URL you must instantiate the `LinkID` object. @@ -345,6 +375,7 @@ Fields list: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/b - Send Locations - Send Contacts - Send Lists +- Send Buttons - Upload media resources to WhatsApp servers - Download media resources from WhatsApp servers - Mark messages as read From 35ec5f6d8666f5d982b7201e41e928b168f10bc5 Mon Sep 17 00:00:00 2001 From: Derrick Obedgiu Date: Sun, 13 Aug 2023 02:29:40 +0300 Subject: [PATCH 2/6] add sendButton method --- src/WhatsAppCloudApi.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/WhatsAppCloudApi.php b/src/WhatsAppCloudApi.php index ad15cb5..1fadd12 100644 --- a/src/WhatsAppCloudApi.php +++ b/src/WhatsAppCloudApi.php @@ -6,6 +6,8 @@ use Netflie\WhatsAppCloudApi\Message\Contact\Phone; use Netflie\WhatsAppCloudApi\Message\Media\MediaID; use Netflie\WhatsAppCloudApi\Message\OptionsList\Action; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\Button; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; use Netflie\WhatsAppCloudApi\Message\Template\Component; class WhatsAppCloudApi @@ -288,6 +290,22 @@ public function sendList(string $to, string $header, string $body, string $foote return $this->client->sendMessage($request); } + public function sendButton(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null): Response + { + $message = new Message\ButtonReplyMessage( + $to, $body, $action, $header, $footer + ); + + $request = new Request\MessageRequest\RequestButtonReplyMessage( + $message, + $this->app->accessToken(), + $this->app->fromPhoneNumberId(), + $this->timeout + ); + + return $this->client->sendMessage($request); + } + /** * Upload a media file (image, audio, video...) to Facebook servers. * From 758f2da9fa8c70d3bcbc659aa4df0c0316b57101 Mon Sep 17 00:00:00 2001 From: Derrick Obedgiu Date: Sun, 13 Aug 2023 02:31:31 +0300 Subject: [PATCH 3/6] Add sendButton --- src/Message/ButtonReply/Button.php | 23 ++++++++++ src/Message/ButtonReply/ButtonAction.php | 31 +++++++++++++ src/Message/ButtonReplyMessage.php | 44 +++++++++++++++++++ .../RequestButtonReplyMessage.php | 42 ++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 src/Message/ButtonReply/Button.php create mode 100644 src/Message/ButtonReply/ButtonAction.php create mode 100644 src/Message/ButtonReplyMessage.php create mode 100644 src/Request/MessageRequest/RequestButtonReplyMessage.php diff --git a/src/Message/ButtonReply/Button.php b/src/Message/ButtonReply/Button.php new file mode 100644 index 0000000..779ddf0 --- /dev/null +++ b/src/Message/ButtonReply/Button.php @@ -0,0 +1,23 @@ +id = $id; + $this->title = $title; + } + + public function id(): string { + return $this->id; + } + + public function title(): string { + return $this->title; + } + +} \ No newline at end of file diff --git a/src/Message/ButtonReply/ButtonAction.php b/src/Message/ButtonReply/ButtonAction.php new file mode 100644 index 0000000..025d9f1 --- /dev/null +++ b/src/Message/ButtonReply/ButtonAction.php @@ -0,0 +1,31 @@ +buttons = $buttons; + } + + public function buttons(): array { + $buttonActions = []; + + foreach ($this->buttons as $button) { + $buttonActions[] = [ + "type" => "reply", + "reply" => [ + "id" => $button->id(), + "title" => $button->title() + ] + ]; + } + + return $buttonActions; + } + +} \ No newline at end of file diff --git a/src/Message/ButtonReplyMessage.php b/src/Message/ButtonReplyMessage.php new file mode 100644 index 0000000..bd55ead --- /dev/null +++ b/src/Message/ButtonReplyMessage.php @@ -0,0 +1,44 @@ +body = $body; + $this->action = $action; + $this->header = $header; + $this->footer = $footer; + + parent::__construct($to); + } + + public function header(): ?string { + return $this->header; + } + + public function body(): string { + return $this->body; + } + + public function action(): ButtonAction { + return $this->action; + } + + public function footer(): ?string { + return $this->footer; + } + +} \ No newline at end of file diff --git a/src/Request/MessageRequest/RequestButtonReplyMessage.php b/src/Request/MessageRequest/RequestButtonReplyMessage.php new file mode 100644 index 0000000..9e63261 --- /dev/null +++ b/src/Request/MessageRequest/RequestButtonReplyMessage.php @@ -0,0 +1,42 @@ + $this->message->messagingProduct(), + 'recipient_type' => $this->message->recipientType(), + 'to' => $this->message->to(), + 'type' => 'interactive', + 'interactive' => [ + 'type' => 'button', + 'body' => ['text' => $this->message->body()], + 'action' => ['buttons' => $this->message->action()->buttons()] + ] + ]; + + if($this->message->header()) { + $body['interactive']['header'] = [ + 'type' => 'text', + 'text' => $this->message->header() + ]; + } + + if($this->message->footer()) { + $body['interactive']['footer'] = [ + 'type' => 'text', + 'text' => $this->message->footer() + ]; + } + + return $body; + + } + +} \ No newline at end of file From e30562d4f6701113464f5f465168f21afd7ab9b5 Mon Sep 17 00:00:00 2001 From: Ian Rothmann Date: Mon, 21 Aug 2023 17:11:26 +0200 Subject: [PATCH 4/6] Footer fix, linting and tests Code linting, removing the "type" key from the footer, unit and integration tests that passes. --- src/Message/ButtonReply/Button.php | 34 ++++---- src/Message/ButtonReplyMessage.php | 80 ++++++++++--------- .../RequestButtonReplyMessage.php | 52 ++++++------ tests/Integration/WhatsAppCloudApiTest.php | 25 ++++++ tests/Unit/WhatsAppCloudApiTest.php | 67 ++++++++++++++++ 5 files changed, 177 insertions(+), 81 deletions(-) diff --git a/src/Message/ButtonReply/Button.php b/src/Message/ButtonReply/Button.php index 779ddf0..f701e64 100644 --- a/src/Message/ButtonReply/Button.php +++ b/src/Message/ButtonReply/Button.php @@ -2,22 +2,24 @@ namespace Netflie\WhatsAppCloudApi\Message\ButtonReply; -class Button { +class Button +{ + private $id; + private $title; - private $id; - private $title; + public function __construct(string $id, string $title) + { + $this->id = $id; + $this->title = $title; + } - public function __construct(string $id, string $title) { - $this->id = $id; - $this->title = $title; - } + public function id(): string + { + return $this->id; + } - public function id(): string { - return $this->id; - } - - public function title(): string { - return $this->title; - } - -} \ No newline at end of file + public function title(): string + { + return $this->title; + } +} diff --git a/src/Message/ButtonReplyMessage.php b/src/Message/ButtonReplyMessage.php index bd55ead..8e58df4 100644 --- a/src/Message/ButtonReplyMessage.php +++ b/src/Message/ButtonReplyMessage.php @@ -4,41 +4,45 @@ use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; -class ButtonReplyMessage extends Message { - - protected string $type = 'button'; - - private ?string $header; - - private string $body; - - private ?string $footer; - - private ButtonAction $action; - - public function __construct(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null) { - $this->body = $body; - $this->action = $action; - $this->header = $header; - $this->footer = $footer; - - parent::__construct($to); - } - - public function header(): ?string { - return $this->header; - } - - public function body(): string { - return $this->body; - } - - public function action(): ButtonAction { - return $this->action; - } - - public function footer(): ?string { - return $this->footer; - } - -} \ No newline at end of file +class ButtonReplyMessage extends Message +{ + protected string $type = 'button'; + + private ?string $header; + + private string $body; + + private ?string $footer; + + private ButtonAction $action; + + public function __construct(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null) + { + $this->body = $body; + $this->action = $action; + $this->header = $header; + $this->footer = $footer; + + parent::__construct($to); + } + + public function header(): ?string + { + return $this->header; + } + + public function body(): string + { + return $this->body; + } + + public function action(): ButtonAction + { + return $this->action; + } + + public function footer(): ?string + { + return $this->footer; + } +} diff --git a/src/Request/MessageRequest/RequestButtonReplyMessage.php b/src/Request/MessageRequest/RequestButtonReplyMessage.php index 9e63261..cd9fb2a 100644 --- a/src/Request/MessageRequest/RequestButtonReplyMessage.php +++ b/src/Request/MessageRequest/RequestButtonReplyMessage.php @@ -2,41 +2,39 @@ namespace Netflie\WhatsAppCloudApi\Request\MessageRequest; -use Netflie\WhatsAppCloudApi\Message\ButtonReplyMessage; use Netflie\WhatsAppCloudApi\Request\MessageRequest; -class RequestButtonReplyMessage extends MessageRequest { - - public function body(): array { +class RequestButtonReplyMessage extends MessageRequest +{ + public function body(): array + { $body = [ - 'messaging_product' => $this->message->messagingProduct(), - 'recipient_type' => $this->message->recipientType(), - 'to' => $this->message->to(), - 'type' => 'interactive', - 'interactive' => [ - 'type' => 'button', - 'body' => ['text' => $this->message->body()], - 'action' => ['buttons' => $this->message->action()->buttons()] - ] + 'messaging_product' => $this->message->messagingProduct(), + 'recipient_type' => $this->message->recipientType(), + 'to' => $this->message->to(), + 'type' => 'interactive', + 'interactive' => [ + 'type' => 'button', + 'body' => ['text' => $this->message->body()], + 'action' => ['buttons' => $this->message->action()->buttons()], + ], ]; - if($this->message->header()) { - $body['interactive']['header'] = [ - 'type' => 'text', - 'text' => $this->message->header() - ]; + if ($this->message->header()) { + $body['interactive']['header'] = [ + 'type' => 'text', + 'text' => $this->message->header(), + ]; } - if($this->message->footer()) { - $body['interactive']['footer'] = [ - 'type' => 'text', - 'text' => $this->message->footer() - ]; + if ($this->message->footer()) { + $body['interactive']['footer'] = [ + 'text' => $this->message->footer(), + ]; } - + return $body; - - } -} \ No newline at end of file + } +} diff --git a/tests/Integration/WhatsAppCloudApiTest.php b/tests/Integration/WhatsAppCloudApiTest.php index a6a1044..51ff656 100644 --- a/tests/Integration/WhatsAppCloudApiTest.php +++ b/tests/Integration/WhatsAppCloudApiTest.php @@ -2,6 +2,8 @@ namespace Netflie\WhatsAppCloudApi\Tests\Integration; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\Button; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; use Netflie\WhatsAppCloudApi\Message\Contact\ContactName; use Netflie\WhatsAppCloudApi\Message\Contact\Phone; use Netflie\WhatsAppCloudApi\Message\Contact\PhoneType; @@ -258,6 +260,29 @@ public function test_send_list() $this->assertEquals(false, $response->isError()); } + public function test_send_reply_buttons() + { + $buttonRows = [ + new Button('button-1', 'Yes'), + new Button('button-2', 'No'), + new Button('button-3', 'Not Now'), + ]; + $buttonAction = new ButtonAction($buttonRows); + $header = 'RATE US'; + $footer = 'Please choose an option'; + + $response = $this->whatsapp_app_cloud_api->sendButton( + WhatsAppCloudApiTestConfiguration::$to_phone_number_id, + 'Would you like to rate us?', + $buttonAction, + $header, + $footer + ); + + $this->assertEquals(200, $response->httpStatusCode()); + $this->assertEquals(false, $response->isError()); + } + public function test_upload_media() { $response = $this->whatsapp_app_cloud_api->uploadMedia('tests/Support/netflie.png'); diff --git a/tests/Unit/WhatsAppCloudApiTest.php b/tests/Unit/WhatsAppCloudApiTest.php index c859184..2601e89 100644 --- a/tests/Unit/WhatsAppCloudApiTest.php +++ b/tests/Unit/WhatsAppCloudApiTest.php @@ -6,6 +6,8 @@ use Netflie\WhatsAppCloudApi\Client; use Netflie\WhatsAppCloudApi\Http\ClientHandler; use Netflie\WhatsAppCloudApi\Http\RawResponse; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\Button; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; use Netflie\WhatsAppCloudApi\Message\Contact\ContactName; use Netflie\WhatsAppCloudApi\Message\Contact\Phone; use Netflie\WhatsAppCloudApi\Message\Contact\PhoneType; @@ -897,6 +899,71 @@ public function test_send_list() $this->assertEquals(false, $response->isError()); } + public function test_send_reply_buttons() + { + $to = $this->faker->phoneNumber; + $url = $this->buildMessageRequestUri(); + + $buttonRows = [ + ['id' => $this->faker->uuid, 'title' => $this->faker->text(10)], + ['id' => $this->faker->uuid, 'title' => $this->faker->text(10)], + ['id' => $this->faker->uuid, 'title' => $this->faker->text(10)], + ]; + $buttonAction = ['buttons' => []]; + + foreach($buttonRows as $button) { + $buttonAction['buttons'][] = [ + 'type' => 'reply', + 'reply' => $button, + ]; + } + + $message = $this->faker->text(50); + $header = $this->faker->text(50); + $footer = $this->faker->text(50); + + $body = [ + 'messaging_product' => 'whatsapp', + 'recipient_type' => 'individual', + 'to' => $to, + 'type' => 'interactive', + 'interactive' => [ + 'type' => 'button', + 'body' => ['text' => $message], + 'action' => $buttonAction, + 'header' => ['type' => 'text', 'text' => $header], + 'footer' => ['text' => $footer], + ], + ]; + $headers = [ + 'Authorization' => 'Bearer ' . $this->access_token, + ]; + + $this->client_handler + ->postJsonData($url, $body, $headers, Argument::type('int')) + ->shouldBeCalled() + ->willReturn(new RawResponse($headers, $this->successfulMessageNodeResponse(), 200)); + + $actionButtons = []; + + foreach ($buttonRows as $button) { + $actionButtons[] = new Button($button['id'], $button['title']); + } + + $response = $this->whatsapp_app_cloud_api->sendButton( + $to, + $message, + new ButtonAction($actionButtons), + $header, + $footer + ); + + $this->assertEquals(200, $response->httpStatusCode()); + $this->assertEquals(json_decode($this->successfulMessageNodeResponse(), true), $response->decodedBody()); + $this->assertEquals($this->successfulMessageNodeResponse(), $response->body()); + $this->assertEquals(false, $response->isError()); + } + public function test_upload_media() { $url = $this->buildMediaRequestUri(); From d4964da9229924affa978230a16ef283984644db Mon Sep 17 00:00:00 2001 From: Ian Rothmann Date: Mon, 11 Sep 2023 19:26:57 +0200 Subject: [PATCH 5/6] StyleCI issues for Reply Buttons --- src/Message/ButtonReply/ButtonAction.php | 43 +++++++++---------- .../RequestButtonReplyMessage.php | 2 - src/WhatsAppCloudApi.php | 27 ++++++------ tests/Unit/WhatsAppCloudApiTest.php | 2 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Message/ButtonReply/ButtonAction.php b/src/Message/ButtonReply/ButtonAction.php index 025d9f1..09c5d9c 100644 --- a/src/Message/ButtonReply/ButtonAction.php +++ b/src/Message/ButtonReply/ButtonAction.php @@ -2,30 +2,29 @@ namespace Netflie\WhatsAppCloudApi\Message\ButtonReply; -use Netflie\WhatsAppCloudApi\Message\ButtonReply\Button; +class ButtonAction +{ + private $buttons; -class ButtonAction { + public function __construct(array $buttons) + { + $this->buttons = $buttons; + } - private $buttons; + public function buttons(): array + { + $buttonActions = []; - public function __construct(array $buttons) { - $this->buttons = $buttons; - } - - public function buttons(): array { - $buttonActions = []; + foreach ($this->buttons as $button) { + $buttonActions[] = [ + "type" => "reply", + "reply" => [ + "id" => $button->id(), + "title" => $button->title(), + ], + ]; + } - foreach ($this->buttons as $button) { - $buttonActions[] = [ - "type" => "reply", - "reply" => [ - "id" => $button->id(), - "title" => $button->title() - ] - ]; + return $buttonActions; } - - return $buttonActions; - } - -} \ No newline at end of file +} diff --git a/src/Request/MessageRequest/RequestButtonReplyMessage.php b/src/Request/MessageRequest/RequestButtonReplyMessage.php index cd9fb2a..4c3d287 100644 --- a/src/Request/MessageRequest/RequestButtonReplyMessage.php +++ b/src/Request/MessageRequest/RequestButtonReplyMessage.php @@ -8,7 +8,6 @@ class RequestButtonReplyMessage extends MessageRequest { public function body(): array { - $body = [ 'messaging_product' => $this->message->messagingProduct(), 'recipient_type' => $this->message->recipientType(), @@ -35,6 +34,5 @@ public function body(): array } return $body; - } } diff --git a/src/WhatsAppCloudApi.php b/src/WhatsAppCloudApi.php index 1fadd12..0db05a3 100644 --- a/src/WhatsAppCloudApi.php +++ b/src/WhatsAppCloudApi.php @@ -2,12 +2,11 @@ namespace Netflie\WhatsAppCloudApi; +use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; use Netflie\WhatsAppCloudApi\Message\Contact\ContactName; use Netflie\WhatsAppCloudApi\Message\Contact\Phone; use Netflie\WhatsAppCloudApi\Message\Media\MediaID; use Netflie\WhatsAppCloudApi\Message\OptionsList\Action; -use Netflie\WhatsAppCloudApi\Message\ButtonReply\Button; -use Netflie\WhatsAppCloudApi\Message\ButtonReply\ButtonAction; use Netflie\WhatsAppCloudApi\Message\Template\Component; class WhatsAppCloudApi @@ -290,21 +289,25 @@ public function sendList(string $to, string $header, string $body, string $foote return $this->client->sendMessage($request); } - public function sendButton(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null): Response - { + public function sendButton(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null): Response + { $message = new Message\ButtonReplyMessage( - $to, $body, $action, $header, $footer + $to, + $body, + $action, + $header, + $footer ); - + $request = new Request\MessageRequest\RequestButtonReplyMessage( - $message, - $this->app->accessToken(), - $this->app->fromPhoneNumberId(), - $this->timeout + $message, + $this->app->accessToken(), + $this->app->fromPhoneNumberId(), + $this->timeout ); - + return $this->client->sendMessage($request); - } + } /** * Upload a media file (image, audio, video...) to Facebook servers. diff --git a/tests/Unit/WhatsAppCloudApiTest.php b/tests/Unit/WhatsAppCloudApiTest.php index 2601e89..c5995f2 100644 --- a/tests/Unit/WhatsAppCloudApiTest.php +++ b/tests/Unit/WhatsAppCloudApiTest.php @@ -911,7 +911,7 @@ public function test_send_reply_buttons() ]; $buttonAction = ['buttons' => []]; - foreach($buttonRows as $button) { + foreach ($buttonRows as $button) { $buttonAction['buttons'][] = [ 'type' => 'reply', 'reply' => $button, From 5b65958bf2c507299a4cf4914b315b1ab5e53ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Albarca?= Date: Sun, 19 Nov 2023 16:48:40 +0100 Subject: [PATCH 6/6] button-reply: add "reply to" feature for buttons --- src/Message/ButtonReplyMessage.php | 4 ++-- .../RequestButtonReplyMessage.php | 4 ++++ src/WhatsAppCloudApi.php | 3 ++- tests/Unit/WhatsAppCloudApiTest.php | 20 ++++++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Message/ButtonReplyMessage.php b/src/Message/ButtonReplyMessage.php index 8e58df4..0053456 100644 --- a/src/Message/ButtonReplyMessage.php +++ b/src/Message/ButtonReplyMessage.php @@ -16,14 +16,14 @@ class ButtonReplyMessage extends Message private ButtonAction $action; - public function __construct(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null) + public function __construct(string $to, string $body, ButtonAction $action, ?string $header = null, ?string $footer = null, ?string $reply_to = null) { $this->body = $body; $this->action = $action; $this->header = $header; $this->footer = $footer; - parent::__construct($to); + parent::__construct($to, $reply_to); } public function header(): ?string diff --git a/src/Request/MessageRequest/RequestButtonReplyMessage.php b/src/Request/MessageRequest/RequestButtonReplyMessage.php index 4c3d287..ab3dc6b 100644 --- a/src/Request/MessageRequest/RequestButtonReplyMessage.php +++ b/src/Request/MessageRequest/RequestButtonReplyMessage.php @@ -33,6 +33,10 @@ public function body(): array ]; } + if ($this->message->replyTo()) { + $body['context']['message_id'] = $this->message->replyTo(); + } + return $body; } } diff --git a/src/WhatsAppCloudApi.php b/src/WhatsAppCloudApi.php index 0db05a3..bd46734 100644 --- a/src/WhatsAppCloudApi.php +++ b/src/WhatsAppCloudApi.php @@ -296,7 +296,8 @@ public function sendButton(string $to, string $body, ButtonAction $action, ?stri $body, $action, $header, - $footer + $footer, + $this->reply_to ); $request = new Request\MessageRequest\RequestButtonReplyMessage( diff --git a/tests/Unit/WhatsAppCloudApiTest.php b/tests/Unit/WhatsAppCloudApiTest.php index c5995f2..c04e2f6 100644 --- a/tests/Unit/WhatsAppCloudApiTest.php +++ b/tests/Unit/WhatsAppCloudApiTest.php @@ -903,6 +903,7 @@ public function test_send_reply_buttons() { $to = $this->faker->phoneNumber; $url = $this->buildMessageRequestUri(); + $reply_to = $this->faker->uuid; $buttonRows = [ ['id' => $this->faker->uuid, 'title' => $this->faker->text(10)], @@ -934,6 +935,9 @@ public function test_send_reply_buttons() 'header' => ['type' => 'text', 'text' => $header], 'footer' => ['text' => $footer], ], + 'context' => [ + 'message_id' => $reply_to, + ], ]; $headers = [ 'Authorization' => 'Bearer ' . $this->access_token, @@ -950,13 +954,15 @@ public function test_send_reply_buttons() $actionButtons[] = new Button($button['id'], $button['title']); } - $response = $this->whatsapp_app_cloud_api->sendButton( - $to, - $message, - new ButtonAction($actionButtons), - $header, - $footer - ); + $response = $this->whatsapp_app_cloud_api + ->replyTo($reply_to) + ->sendButton( + $to, + $message, + new ButtonAction($actionButtons), + $header, + $footer + ); $this->assertEquals(200, $response->httpStatusCode()); $this->assertEquals(json_decode($this->successfulMessageNodeResponse(), true), $response->decodedBody());