]> git.angelumana.com Git - diane/.git/commitdiff
Dynamically use the user's number rather than having a hard coded number to send to main origin/HEAD origin/main
authoribidyouadu <angel.d.umana@gmail.com>
Sat, 9 Sep 2023 22:02:12 +0000 (22:02 +0000)
committeribidyouadu <angel.d.umana@gmail.com>
Sat, 9 Sep 2023 22:02:12 +0000 (22:02 +0000)
main.py
utils.py

diff --git a/main.py b/main.py
index 6bc11b6a256a3a70ce5c637163200307e59d4907..7041bc8383bd879dbad0b749ef0d56764071a2df 100644 (file)
--- a/main.py
+++ b/main.py
@@ -25,7 +25,7 @@ r.rpush(conversation_key, init_payload)
 
 
 @app.post("/")
 
 
 @app.post("/")
-async def reply(Body: str=Form()):
+async def reply(Body: str=Form(), From: str=Form()):
     # Add to payload for OpenAI API
     input_message = {
         "role": "user",
     # Add to payload for OpenAI API
     input_message = {
         "role": "user",
@@ -59,6 +59,6 @@ async def reply(Body: str=Form()):
     logger.info("Stored the response in the database.")
 
     # Send response to user
     logger.info("Stored the response in the database.")
 
     # Send response to user
-    send_message(TO_NUMBER, output_body)
+    send_message(From, output_body)
 
     return True
\ No newline at end of file
 
     return True
\ No newline at end of file
index bea97c9cf7bc5a823893e82ec26d83af74ea0524..675b9b11726b8fcea662031e702bda69b88b8a0f 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -15,7 +15,7 @@ def send_message(to_number, body_text):
         message = client.messages.create(
             from_=f"whatsapp:{TWILIO_NUMBER}",
             body=body_text,
         message = client.messages.create(
             from_=f"whatsapp:{TWILIO_NUMBER}",
             body=body_text,
-            to=f"whatsapp:{to_number}"
+            to=f"{to_number}"
             )
         logger.info(f"Message sent to {to_number}: {message.body}")
     except Exception as e:
             )
         logger.info(f"Message sent to {to_number}: {message.body}")
     except Exception as e: