Spaces:
Runtime error
Runtime error
Greg Thompson commited on
Commit ·
e7eca0d
1
Parent(s): b439c42
Add feature to make message based on conditions
Browse files7 unmodified lines8910111213141516171828 unmodified lines474849505152531 unmodified line555657585960612 unmodified lines64656667686970717273747576771 unmodified line7980818283847 unmodified lines# os.environ.get('SUPABASE_URL')def parse_data(data):data_bytes = requests.bodydata_decoded = data_bytes.decode()data_json = json.loads(data_decoded)return data_jsondef generate_message(data_json):""" pending28 unmodified linesprint("DATA JSON")print(data_json)data = {"to": whatsapp_id,# "to": "alan","type": "interactive",1 unmodified line"type": "button",# "header": { },"body": {"text": "Did I answer your question?"},# "footer": { },"action": {2 unmodified lines"type": "reply","reply": {"id": "inquiry-yes","title": "Yes"}},{"type": "reply","reply": {"id": "inquiry-no","title": "No"}}]1 unmodified line}}r = requests.post(f'https://whatsapp.turn.io/v1/messages', data=json.dumps(data), headers=headers)print("==================")print("Headers")7 unmodified lines891011121328 unmodified lines4243444546474849505152535455565758596061626364656667686970711 unmodified line737475767778792 unmodified lines82838485868788899091929394951 unmodified line9798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341357 unmodified lines# os.environ.get('SUPABASE_URL')def generate_message(data_json):""" pending28 unmodified linesprint("DATA JSON")print(data_json)user_message = data_json['message']['text']['body']if user_message == 'add':data = {"preview_url": false,"recipient_type": "individual","to": whatsapp_id,"type": "text","text": {"body": "What's 2+2?"}}elif user_message == 'substract':data = {"preview_url": false,"recipient_type": "individual","to": whatsapp_id,"type": "text","text": {"body": "What's 1-1?"}}else:data = {"to": whatsapp_id,# "to": "alan","type": "interactive",1 unmodified line"type": "button",# "header": { },"body": {"text": "Please choose one of the following options."},# "footer": { },"action": {2 unmodified lines"type": "reply","reply": {"id": "inquiry-yes","title": "add"}},{"type": "reply","reply": {"id": "inquiry-no","title": "subtract"}}]1 unmodified line}}# data = {# "to": whatsapp_id,# # "to": "alan",# "type": "interactive",# "interactive": {# "type": "button",# # "header": { },# "body": {# "text": "Did I answer your question?"# },# # "footer": { },# "action": {# "buttons": [# {# "type": "reply",# "reply": {# "id": "inquiry-yes",# "title": "Yes"# }# },# {# "type": "reply",# "reply": {# "id": "inquiry-no",# "title": "No"# }# }# ]# }# }# }r = requests.post(f'https://whatsapp.turn.io/v1/messages', data=json.dumps(data), headers=headers)print("==================")print("Headers")
mathtext_fastapi/conversation_manager.py+60-9