Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -101,7 +101,13 @@ def generate_answer_with_groq(question, context):
|
|
| 101 |
|
| 102 |
# --- Twilio Functions ---
|
| 103 |
def fetch_latest_incoming_message(client, conversation_sid):
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
for msg in reversed(messages):
|
| 106 |
if msg.author.startswith("whatsapp:"):
|
| 107 |
return {
|
|
|
|
| 101 |
|
| 102 |
# --- Twilio Functions ---
|
| 103 |
def fetch_latest_incoming_message(client, conversation_sid):
|
| 104 |
+
try:
|
| 105 |
+
messages = client.conversations.conversations(convo_sid).messages.list()
|
| 106 |
+
except TwilioRestException as e:
|
| 107 |
+
if e.status == 404:
|
| 108 |
+
print(f"Conversation {convo_sid} not found, skipping...")
|
| 109 |
+
continue
|
| 110 |
+
#messages = client.conversations.v1.conversations(conversation_sid).messages.list(limit=10)
|
| 111 |
for msg in reversed(messages):
|
| 112 |
if msg.author.startswith("whatsapp:"):
|
| 113 |
return {
|