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
已發問 約 4 個月前
Elisha

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

10月10日下午1:09
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.

10月13日上午6:33
已選擇的回答
1

same issue and no support

11月12日上午12:03
Mayur
1

Same issue, please help with resolve this ASAP!

11月18日上午2:26
Lidor