masadonline commited on
Commit
3608d2f
·
verified ·
1 Parent(s): 1039466

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -211,6 +211,7 @@ def start_conversation_monitor(client, index, embed_model, text_chunks):
211
  latest_msg = fetch_latest_incoming_message(client, convo_sid)
212
  if latest_msg:
213
  msg_time = latest_msg["timestamp"]
 
214
  if convo_sid not in last_processed_timestamp or msg_time > last_processed_timestamp[convo_sid]:
215
  last_processed_timestamp[convo_sid] = msg_time
216
  question = latest_msg["body"]
@@ -222,10 +223,13 @@ def start_conversation_monitor(client, index, embed_model, text_chunks):
222
  time.sleep(5)
223
 
224
  for convo in client.conversations.v1.conversations.list():
 
 
225
  if convo.sid not in processed_convos:
226
  processed_convos.add(convo.sid)
227
  threading.Thread(target=poll_convo, args=(convo.sid,), daemon=True).start()
228
 
 
229
  # ---------------- Main Entry ----------------
230
  if __name__ == "__main__":
231
  st.title("🤖 ToyBot WhatsApp Assistant")
 
211
  latest_msg = fetch_latest_incoming_message(client, convo_sid)
212
  if latest_msg:
213
  msg_time = latest_msg["timestamp"]
214
+ if msg_time > APP_START_TIME:
215
  if convo_sid not in last_processed_timestamp or msg_time > last_processed_timestamp[convo_sid]:
216
  last_processed_timestamp[convo_sid] = msg_time
217
  question = latest_msg["body"]
 
223
  time.sleep(5)
224
 
225
  for convo in client.conversations.v1.conversations.list():
226
+ # convo.date_created is a datetime object in UTC, compare it with APP_START_TIME
227
+ if convo.date_created is not None and convo.date_created > APP_START_TIME:
228
  if convo.sid not in processed_convos:
229
  processed_convos.add(convo.sid)
230
  threading.Thread(target=poll_convo, args=(convo.sid,), daemon=True).start()
231
 
232
+
233
  # ---------------- Main Entry ----------------
234
  if __name__ == "__main__":
235
  st.title("🤖 ToyBot WhatsApp Assistant")