Arafath10 commited on
Commit
66e97f3
·
verified ·
1 Parent(s): 8537b0d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -10
main.py CHANGED
@@ -32,16 +32,14 @@ app.add_middleware(
32
  @app.post("/whatsapp")
33
  async def reply_whatsapp(request: Request):
34
  form_data = await request.form()
35
- try:
36
- num_media = int(form_data.get("NumMedia", 0))
37
- except (ValueError, TypeError):
38
- raise HTTPException(status_code=400, detail="Invalid request: invalid or missing NumMedia parameter")
39
 
40
  response = MessagingResponse()
41
- if not num_media:
42
- msg = response.message("Send us an image!")
43
- else:
44
- msg = response.message("Thanks for the image. Here's one for you!")
45
- msg.media(GOOD_BOY_URL)
46
- return PlainTextResponse(str(response))
47
 
 
32
  @app.post("/whatsapp")
33
  async def reply_whatsapp(request: Request):
34
  form_data = await request.form()
35
+ num_media = int(form_data.get("NumMedia", 0))
36
+ from_number = form_data.get("From")
37
+ message_body = form_data.get("Body")
 
38
 
39
  response = MessagingResponse()
40
+
41
+ msg = response.message(f"hi your number is {from_number} and you sayed {message_body}")
42
+ msg.media(GOOD_BOY_URL)
43
+
44
+ return str(response)
 
45