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 lines8910111213141511121328 unmodified lines424344454647504849505152535455565758596061626364656667686970711 unmodified line73747558767778792 unmodified lines828384678586878889909174929394951 unmodified line9798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341357 unmodified lines
# os.environ.get('SUPABASE_URL')
def parse_data(data): data_bytes = requests.body data_decoded = data_bytes.decode() data_json = json.loads(data_decoded) return data_json
def generate_message(data_json): """ pending28 unmodified lines print("DATA JSON") print(data_json)
user_message = data_json['message']['text']['body']
if user_message == 'add': data = { 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": "Did I answer your question?" "text": "Please choose one of the following options." }, # "footer": { }, "action": {2 unmodified lines "type": "reply", "reply": { "id": "inquiry-yes", "title": "Yes" "title": "add" } }, { "type": "reply", "reply": { "id": "inquiry-no", "title": "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