WhatsApp Cloud API: Webhook Not Receiving POST Requests on User Messages
2

Hi everyone,

I'm using the WhatsApp Cloud API and have set up a webhook using ngrok. The webhook verification (GET request) works fine, and I receive POST requests when testing from the dev app. However, when sending or receiving messages from users, the webhook doesn't get triggered.

Here's my Flask code:

from flask import Flask, request, jsonify

app = Flask(name)

@app.route('/webhook', methods=['GET', 'POST']) def webhook(): if request.method == 'GET': challenge = request.args.get('hub.challenge') verify_token = request.args.get('hub.verify_token') if verify_token == 'secret token': return challenge, 200 else: return "Verification token mismatch", 403

if request.method == 'POST':
    # Handle incoming messages here
    data = request.json
    if data.get('object'):
        entry = data['entry'][0]
        changes = entry['changes'][0]
        value = changes['value']
        messages = value.get('messages')
        print(data)
        if messages:
            for message in messages:
                print(f"Received message: {message}")
                return jsonify(status="success")

    return jsonify(status="ignored")

if name == 'main': app.run(port=5000, debug=True)

Issue:

I'm getting the GET request for webhook verification and POST requests when testing in the dev app. However, sending or receiving messages from users doesn't trigger any POST requests to my webhook. Any ideas on what might be going wrong or how to fix this?

Thanks!

Raghav
Asked about 4 months ago
Elisha

I have been having the same issue, did you manage to resolve this?

October 10 at 1:09 PM
Luciano

I got the same problem on two new phone numbers at different accounts. Meta support could not help me, instead it gave me developers community support. Please, if you fix this issue share the solution here. I'll do the same.

October 13 at 6:33 AM
Selected Answer
1

same issue and no support

November 12 at 12:03 AM
Mayur
1

Same issue, please help with resolve this ASAP!

November 18 at 2:26 AM
Lidor