Skip to content

Commit

Permalink
Update security PIN handling in alternative_helper.py and sms-helper/…
Browse files Browse the repository at this point in the history
…__init__.py
  • Loading branch information
lperezmo committed Jan 17, 2024
1 parent 3adb448 commit 2002589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions alternative_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#------------------------------------#
ACCOUNT_SID = os.environ["ACCOUNT_SID"]
AUTH_TOKEN = os.environ["AUTH_TOKEN"]
SEC_PIN = os.environ["SECURITY_PIN"]

#------------------------------------#
# OpenAI and Twilio Clients
Expand All @@ -21,14 +22,14 @@
#------------------------------------#
# Security check
#------------------------------------#
def process_incoming_message(PIN, incoming_message, send_to, send_from):
def process_incoming_message(security_pin, incoming_message, send_to, send_from):
"""
Generate a reply based on the incoming message.
Parameters
----------
PIN : str
Security PIN
security_pin : str
Security security_pin
incoming_message : str
Incoming message from Twilio
Expand All @@ -37,7 +38,7 @@ def process_incoming_message(PIN, incoming_message, send_to, send_from):
message : str
Reply message
"""
if incoming_message.strip() == PIN:
if incoming_message.strip() == security_pin:
return """Welcome to Hess Services AI Assistant.
- I can schedule calls and text reminders for you.
- I can also just answer questions, within reason.
Expand All @@ -46,13 +47,13 @@ def process_incoming_message(PIN, incoming_message, send_to, send_from):
messages = CLIENT.messages.list(from_=send_to, to=send_from)
sent_pin = False
for message in messages:
if message.body.strip() == PIN:
if message.body.strip() == security_pin:
sent_pin = True
if sent_pin:
follow_up_reply = get_follow_up_text(incoming_message)
return follow_up_reply
else:
return "Please provide security PIN to continue"
return f"Please provide security PIN to continue. Hint: {security_pin}"

#------------------------------------#
# Current time
Expand Down
2 changes: 1 addition & 1 deletion sms-helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
# This one returns the response message as the HttpResponse.
#--------------------------------------------------------------------------#

response_for_user = alternative_helper.process_incoming_message(os.environ["SECURITY_PIN"],
response_for_user = alternative_helper.process_incoming_message(alternative_helper.SEC_PIN,
send_to,
send_from,
incoming_message)
Expand Down

0 comments on commit 2002589

Please sign in to comment.