Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,11 +116,18 @@ def send_twilio_message(client, conversation_sid, body):
|
|
116 |
def get_latest_whatsapp_conversation_sid(client):
|
117 |
conversations = client.conversations.v1.conversations.list(limit=20)
|
118 |
for convo in conversations:
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
return conversations[0].sid if conversations else None
|
123 |
|
|
|
124 |
# Streamlit UI
|
125 |
st.set_page_config(page_title="Quasa β A Smart WhatsApp Chatbot", layout="wide")
|
126 |
st.title("π± Quasa β A Smart WhatsApp Chatbot")
|
|
|
116 |
def get_latest_whatsapp_conversation_sid(client):
|
117 |
conversations = client.conversations.v1.conversations.list(limit=20)
|
118 |
for convo in conversations:
|
119 |
+
try:
|
120 |
+
participants = client.conversations.v1.conversations(convo.sid).participants.list()
|
121 |
+
for p in participants:
|
122 |
+
if p.identity and p.identity.startswith("whatsapp:"):
|
123 |
+
return convo.sid
|
124 |
+
if p.messaging_binding and p.messaging_binding.get("address", "").startswith("whatsapp:"):
|
125 |
+
return convo.sid
|
126 |
+
except Exception as e:
|
127 |
+
continue
|
128 |
return conversations[0].sid if conversations else None
|
129 |
|
130 |
+
|
131 |
# Streamlit UI
|
132 |
st.set_page_config(page_title="Quasa β A Smart WhatsApp Chatbot", layout="wide")
|
133 |
st.title("π± Quasa β A Smart WhatsApp Chatbot")
|