raghavNCI
commited on
Commit
·
047bda7
1
Parent(s):
4691e67
wa gateway plain text response
Browse files- routes/wa_gateway.py +3 -2
routes/wa_gateway.py
CHANGED
@@ -3,7 +3,7 @@ from fastapi import APIRouter, Request
|
|
3 |
import os
|
4 |
import requests
|
5 |
from dotenv import load_dotenv
|
6 |
-
from fastapi.responses import JSONResponse
|
7 |
|
8 |
load_dotenv()
|
9 |
|
@@ -18,7 +18,8 @@ RECIPIENT_NUMBER = "+353 89 949 5777" # or pass dynamically
|
|
18 |
async def verify_webhook(request: Request):
|
19 |
params = request.query_params
|
20 |
if params.get("hub.mode") == "subscribe" and params.get("hub.verify_token") == VERIFY_TOKEN:
|
21 |
-
|
|
|
22 |
return JSONResponse(status_code=403, content={"error": "Verification failed"})
|
23 |
|
24 |
@wa_router.post("/webhook")
|
|
|
3 |
import os
|
4 |
import requests
|
5 |
from dotenv import load_dotenv
|
6 |
+
from fastapi.responses import PlainTextResponse, JSONResponse
|
7 |
|
8 |
load_dotenv()
|
9 |
|
|
|
18 |
async def verify_webhook(request: Request):
|
19 |
params = request.query_params
|
20 |
if params.get("hub.mode") == "subscribe" and params.get("hub.verify_token") == VERIFY_TOKEN:
|
21 |
+
# Return raw plain text (not JSON)
|
22 |
+
return PlainTextResponse(content=params.get("hub.challenge"))
|
23 |
return JSONResponse(status_code=403, content={"error": "Verification failed"})
|
24 |
|
25 |
@wa_router.post("/webhook")
|