one more last time
Browse files
routes/api/whatsapp_webhook.py
CHANGED
@@ -20,8 +20,16 @@ async def whatsapp_webhook_receiver(request: Request):
|
|
20 |
"""
|
21 |
try:
|
22 |
# <<< FIX 1: Assume JSON body directly for incoming_message >>>
|
23 |
-
|
24 |
-
logging.info(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
from_number = None
|
27 |
message_text = None
|
|
|
20 |
"""
|
21 |
try:
|
22 |
# <<< FIX 1: Assume JSON body directly for incoming_message >>>
|
23 |
+
raw_body = await request.body()
|
24 |
+
logging.info(f"Raw webhook body received: {raw_body.decode('utf-8')}")
|
25 |
+
|
26 |
+
try:
|
27 |
+
incoming_message = json.loads(raw_body)
|
28 |
+
logging.info(f"Parsed WhatsApp webhook: {json.dumps(incoming_message, indent=2)}")
|
29 |
+
except Exception as e:
|
30 |
+
logging.error(f"Failed to parse incoming JSON: {e}")
|
31 |
+
return JSONResponse(status_code=400, content={"status": "error", "message": "Invalid JSON payload"})
|
32 |
+
|
33 |
|
34 |
from_number = None
|
35 |
message_text = None
|