Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -134,30 +134,7 @@ if not all([account_sid, auth_token, GROQ_API_KEY]):
|
|
134 |
auth_token = st.text_input("Twilio Auth Token", type="password", value=auth_token or "")
|
135 |
GROQ_API_KEY = st.text_input("GROQ API Key", type="password", value=GROQ_API_KEY or "")
|
136 |
|
137 |
-
|
138 |
-
try:
|
139 |
-
client = Client(account_sid, auth_token)
|
140 |
-
conversations = client.conversations.v1.conversations.list(limit=50)
|
141 |
-
|
142 |
-
for convo in conversations:
|
143 |
-
messages = client.conversations.v1.conversations(convo.sid).messages.list(limit=1)
|
144 |
-
if messages:
|
145 |
-
last_msg = messages[0]
|
146 |
-
if last_msg.author.startswith("whatsapp:"):
|
147 |
-
return convo.sid
|
148 |
-
return None
|
149 |
-
except Exception as e:
|
150 |
-
st.error(f"β Error detecting WhatsApp conversation SID: {e}")
|
151 |
-
return None
|
152 |
-
|
153 |
-
# Auto-detect conversation SID
|
154 |
-
conversation_sid = get_latest_active_whatsapp_conversation_sid(account_sid, auth_token)
|
155 |
-
|
156 |
-
if conversation_sid:
|
157 |
-
st.success(f"β
Auto-detected WhatsApp Conversation SID: `{conversation_sid}`")
|
158 |
-
else:
|
159 |
-
st.warning("β οΈ No active WhatsApp conversation found. Please send a message first.")
|
160 |
-
|
161 |
|
162 |
enable_autorefresh = st.checkbox("π Enable Auto-Refresh", value=True)
|
163 |
interval_seconds = st.selectbox("Refresh Interval (seconds)", options=[5, 10, 15, 30, 60], index=1)
|
|
|
134 |
auth_token = st.text_input("Twilio Auth Token", type="password", value=auth_token or "")
|
135 |
GROQ_API_KEY = st.text_input("GROQ API Key", type="password", value=GROQ_API_KEY or "")
|
136 |
|
137 |
+
conversation_sid = st.text_input("Enter Conversation SID", value="")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
enable_autorefresh = st.checkbox("π Enable Auto-Refresh", value=True)
|
140 |
interval_seconds = st.selectbox("Refresh Interval (seconds)", options=[5, 10, 15, 30, 60], index=1)
|