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!
I have been having the same issue, did you manage to resolve this?
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.
same issue and no support
Same issue, please help with resolve this ASAP!