Spaces:
Running
Running
Chandima Prabhath
commited on
Commit
·
8a638e3
1
Parent(s):
162ca3a
Add chat ID logging to webhook and refine trivia question generation prompt
Browse files
app.py
CHANGED
@@ -583,6 +583,8 @@ async def whatsapp_webhook(request: Request):
|
|
583 |
raise HTTPException(403, "Unauthorized")
|
584 |
try:
|
585 |
data = await request.json()
|
|
|
|
|
586 |
except:
|
587 |
return JSONResponse({"error": "Invalid JSON"}, status_code=400)
|
588 |
if data.get("typeWebhook") != "incomingMessageReceived":
|
@@ -678,7 +680,7 @@ async def whatsapp_webhook(request: Request):
|
|
678 |
# TRIVIA
|
679 |
if low == "/trivia":
|
680 |
raw = generate_llm(
|
681 |
-
"Generate a trivia question and answer in JSON format like this: "
|
682 |
"{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}"
|
683 |
)
|
684 |
def extract_json(text):
|
|
|
583 |
raise HTTPException(403, "Unauthorized")
|
584 |
try:
|
585 |
data = await request.json()
|
586 |
+
chat_id = data["senderData"]["chatId"]
|
587 |
+
print(f"New message from chat ID: {chat_id}")
|
588 |
except:
|
589 |
return JSONResponse({"error": "Invalid JSON"}, status_code=400)
|
590 |
if data.get("typeWebhook") != "incomingMessageReceived":
|
|
|
680 |
# TRIVIA
|
681 |
if low == "/trivia":
|
682 |
raw = generate_llm(
|
683 |
+
"Generate a random trivia question and answer in JSON format like this: "
|
684 |
"{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}"
|
685 |
)
|
686 |
def extract_json(text):
|