Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -148,6 +148,7 @@ def generate_answer_with_groq(question, context):
|
|
148 |
# ---------------- Twilio Integration ----------------
|
149 |
def fetch_latest_incoming_message(client, conversation_sid):
|
150 |
try:
|
|
|
151 |
messages = client.conversations.v1.conversations(conversation_sid).messages.list()
|
152 |
for msg in reversed(messages):
|
153 |
if msg.author.startswith("whatsapp:"):
|
@@ -205,12 +206,13 @@ def setup_knowledge_base():
|
|
205 |
|
206 |
# ---------------- Monitor Twilio Conversations ----------------
|
207 |
def start_conversation_monitor(client, index, embed_model, text_chunks):
|
|
|
208 |
processed_convos = set()
|
209 |
last_processed_timestamp = {}
|
210 |
|
211 |
def poll_convo(convo_sid):
|
212 |
while True:
|
213 |
-
print(f"Twilio SID: {convo_sid}")
|
214 |
latest_msg = fetch_latest_incoming_message(client, convo_sid)
|
215 |
if latest_msg:
|
216 |
msg_time = latest_msg["timestamp"]
|
|
|
148 |
# ---------------- Twilio Integration ----------------
|
149 |
def fetch_latest_incoming_message(client, conversation_sid):
|
150 |
try:
|
151 |
+
print(f"fetch_latest_incoming_message Twilio SID : {conversation_sid}")
|
152 |
messages = client.conversations.v1.conversations(conversation_sid).messages.list()
|
153 |
for msg in reversed(messages):
|
154 |
if msg.author.startswith("whatsapp:"):
|
|
|
206 |
|
207 |
# ---------------- Monitor Twilio Conversations ----------------
|
208 |
def start_conversation_monitor(client, index, embed_model, text_chunks):
|
209 |
+
print(f"start_conversation_monitor: {client}")
|
210 |
processed_convos = set()
|
211 |
last_processed_timestamp = {}
|
212 |
|
213 |
def poll_convo(convo_sid):
|
214 |
while True:
|
215 |
+
print(f"poll_convo Twilio SID: {convo_sid}")
|
216 |
latest_msg = fetch_latest_incoming_message(client, convo_sid)
|
217 |
if latest_msg:
|
218 |
msg_time = latest_msg["timestamp"]
|