enter image description hereI am learning web programming. I am working on adding whatsapp webhook to my web app. My understanding: In my web app, i implemented sending a whatsapp message template programmatically. When a client replies, i want to be able to receive and reply to the client. I followed the tutorial on https://business.whatsapp.com/blog/how-to-use-webhooks-from-whatsapp-business-api in combination with the tutorial in https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks#sample-app-endpoints.
My endpoint has be verifyed usefully. But when i send test message, i do not receive any message in my database. I was expecting the when i send test message/when client sends whatsapp message, which show successful, i should receive it in database.
whatsappcontroller.php
public function handleWebhook(Request $request){ $body = json_decode($request->getContent(), true); if ($body['field'] !== 'messages') { // not from the messages webhook so don't process return response()->json([], 400); } foreach ($body['value']['messages'] as $message) { $review = new Whatsapp(); $review->phonenumber = $message['from']; $review->review = $message['text']['body']; $review->save(); }
Route.php
Route::post('/webhooks', [whatsappController::class, 'handleWebhook']);
What am I not doing good or what do i need to understand about webhook. Because i am expecting that when messages are saved in database, then i can now use a get request url to get all the messages in my web page. Or is this not possible?
enter image description here