部分中斷share-external
I can't receive a notification on whatsaap as soon as a lead fills in a form
1

I would like to receive a whatsaap notification as soon as someone subscribes to my form , for this, I have created a flask server: from flask import Flask, request import requests

app = Flask(name)

Informations de configuration

VERIFY_TOKEN = 'TEST'
ACCESS_TOKEN = '..' WHATSAPP_PHONE_NUMBER_ID = '..' RECIPIENT_PHONE_NUMBER = 'whatsapp:+..'

@app.route('/webhook', methods=['GET']) def verify(): token = request.args.get('hub.verify_token') challenge = request.args.get('hub.challenge') if token == VERIFY_TOKEN: return challenge else: return 'Error, invalid token', 403

@app.route('/webhook', methods=['POST']) def webhook(): data = request.json if data['object'] == 'page': for entry in data['entry']: for lead in entry['changes']: if lead['field'] == 'leadgen': leadgen_id = lead['value']['leadgen_id'] send_whatsapp_notification(leadgen_id) return 'EVENT_RECEIVED', 200

def send_whatsapp_notification(leadgen_id): url = f'https://graph.facebook.com/v11.0/{WHATSAPP_PHONE_NUMBER_ID}/messages' headers = { 'Authorization': f'Bearer {ACCESS_TOKEN}', 'Content-Type': 'application/json' } data = { 'messaging_product': 'whatsapp', 'to': RECIPIENT_PHONE_NUMBER, 'type': 'template', 'template': { 'name': 'hello_world', 'language': {'code': 'en_US'} } } response = requests.post(url, headers=headers, json=data) print(response.json())

if name == 'main': app.run(port=80, debug=True) I also have ngrok so that I can put the application online. I've created an application on meta for developers and I've added a Webhook product, I've put the page on it, I've put my URL link and the token. I then subscribed to leadgen and did a test. However, I don't receive any notification, even when I fill in my own form. I've also created a whatsaap business account and I'm now on whatsaap manager. Now I'm blocked and I don't know what to do?

Hawra
已發問 約 5 個月前