From 8025f7c1e0b235fb7f25c0a0e9be2b65cdd40778 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Wed, 28 Feb 2024 15:14:46 -0800 Subject: [PATCH] added webhook --- routers/facebook_api.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/routers/facebook_api.py b/routers/facebook_api.py index e910211d6..134415405 100644 --- a/routers/facebook_api.py +++ b/routers/facebook_api.py @@ -94,9 +94,21 @@ def fb_connect_whatsapp_redirect(request: Request): "pin": settings.WHATSAPP_2FA_PIN, }, ) - print(r.json()) r.raise_for_status() + # subscript our app to weebhooks for WABA + r = requests.post( + f"https://graph.facebook.com/v19.0/{waba_id}/subscribed_apps?access_token={user_access_token}", + json={ + "override_callback_uri": ( + furl(settings.APP_BASE_URL) + / router.url_path_for(fb_webhook.__name__) + ).tostr(), + "verify_token": settings.FB_WEBHOOK_TOKEN, + }, + ) + r.raise_for_status() + return HTMLResponse( f"Sucessfully Connected to whatsapp! You may now close this page." )