John Landry commited on
Commit
1f3c6b2
1 Parent(s): c6e83ec
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastapi import FastAPI, Request, Query
2
  import logging
3
  from whatsapp_client import WhatsAppWrapper
 
4
 
5
  logger = logging.getLogger()
6
 
@@ -31,8 +32,9 @@ async def verify(
31
  @app.post("/webook")
32
  async def callback(request: Request):
33
  print("============ callback is being called ============")
34
- data = await request.body()
35
- print(data)
 
36
  phone_num = data['entry'][0]['changes'][0]['value']['messages'][0]['from']
37
  mesg_body = data['entry'][0]['changes'][0]['value']['messages'][0]['text']['body']
38
  phone_number_id = data['entry'][0]['changes'][0]['value']['metadata']['phone_number_id']
 
1
  from fastapi import FastAPI, Request, Query
2
  import logging
3
  from whatsapp_client import WhatsAppWrapper
4
+ import json
5
 
6
  logger = logging.getLogger()
7
 
 
32
  @app.post("/webook")
33
  async def callback(request: Request):
34
  print("============ callback is being called ============")
35
+ body = await request.body()
36
+ print(body)
37
+ data = json.loads(data)
38
  phone_num = data['entry'][0]['changes'][0]['value']['messages'][0]['from']
39
  mesg_body = data['entry'][0]['changes'][0]['value']['messages'][0]['text']['body']
40
  phone_number_id = data['entry'][0]['changes'][0]['value']['metadata']['phone_number_id']